export function createApp() {
// create the app instance, injecting both the router and the store
const app = new Vue({
+ // @ts-ignore
render: h => h(App),
})
import Vue from 'vue'
import { PiniaSsr } from '../../src'
+import { mockWarn } from 'jest-mock-warn'
-it('should warn when installed in the browser', () => {
- const mixinSpy = jest.spyOn(Vue, 'mixin')
- const warnSpy = jest.spyOn(console, 'warn')
- Vue.use(PiniaSsr)
- expect(warnSpy).toHaveBeenCalledWith(
- expect.stringMatching(/seems to be used in the browser bundle/i)
- )
- expect(mixinSpy).not.toHaveBeenCalled()
+describe('SSR', () => {
+ mockWarn()
+
+ it('should warn when installed in the browser', () => {
+ const mixinSpy = jest.spyOn(Vue, 'mixin')
+ Vue.use(PiniaSsr)
+ expect(/seems to be used in the client bundle/i).toHaveBeenWarned()
+ expect(mixinSpy).not.toHaveBeenCalled()
+ mixinSpy.mockRestore()
+ })
})
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.1",
"jest": "^25.1.0",
+ "jest-mock-warn": "^1.1.0",
"pascalcase": "^1.0.0",
"prettier": "^1.18.2",
"rimraf": "^3.0.1",
if (!isServer) {
console.warn(
- '`PiniaSsrPlugin` seems to be used in the browser bundle. You should only call it on the server entry: https://github.com/posva/pinia#raw-vue-ssr'
+ '`PiniaSsrPlugin` seems to be used in the client bundle. You should only call it on the server entry: https://github.com/posva/pinia#raw-vue-ssr'
)
return
}
"rootDir": ".",
"baseUrl": "."
},
- "include": ["src/**/*.ts", "nuxt/*.js", "__tests__/**/**.ts"]
+ "include": ["src/**/*.ts", "nuxt/*.js", "__tests__/**/*.ts"]
}
slash "^3.0.0"
stack-utils "^1.0.1"
+jest-mock-warn@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/jest-mock-warn/-/jest-mock-warn-1.1.0.tgz#cb1c8beaa6c6236da2be0f170fd5e6f595adb67b"
+ integrity sha512-Q0EjGIUowgcuH7K1v6KgZ/WtqQaA9kc/TxayKaZKKeTGBn9nC4uKI65nt0O3l8opaPi2VSvG18WcLPEqzowxrQ==
+
jest-mock@^25.5.0:
version "25.5.0"
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-25.5.0.tgz#a91a54dabd14e37ecd61665d6b6e06360a55387a"