From: Eduardo San Martin Morote Date: Tue, 17 Aug 2021 14:44:00 +0000 (+0200) Subject: test: fix running tests X-Git-Tag: @pinia/nuxt@0.0.1~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4fe0536376be4883a7252cbc3371ec427cc62596;p=thirdparty%2Fvuejs%2Fpinia.git test: fix running tests --- diff --git a/jest.config.js b/jest.config.js index f6602a4a..ace2e0b2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ module.exports = { collectCoverage: true, coverageDirectory: 'coverage', coverageReporters: ['html', 'lcov', 'text'], - collectCoverageFrom: ['src/**/*.ts'], + collectCoverageFrom: ['packages/*/src/**/*.ts'], coveragePathIgnorePatterns: [ '/node_modules/', 'src/index.ts', @@ -13,10 +13,15 @@ module.exports = { 'src/deprecated.ts', 'src/vue2-plugin.ts', ], - testMatch: ['/__tests__/**/*.spec.ts'], + testMatch: ['/packages/*/__tests__/**/*.spec.ts'], transform: { '^.+\\.tsx?$': '@sucrase/jest-plugin', }, + moduleNameMapper: { + '^@pinia/(.*?)$': '/packages/$1/src', + '^pinia$': '/packages/pinia/src', + }, + rootDir: __dirname, globals: { __DEV__: true, __TEST__: true, diff --git a/packages/pinia/__tests__/pinia/stores/cart.ts b/packages/pinia/__tests__/pinia/stores/cart.ts index eca0d1f3..b0504268 100644 --- a/packages/pinia/__tests__/pinia/stores/cart.ts +++ b/packages/pinia/__tests__/pinia/stores/cart.ts @@ -1,8 +1,7 @@ import { defineStore } from '../../../src' import { useUserStore } from './user' -export const useCartStore = defineStore({ - id: 'cart', +export const useCartStore = defineStore('cart', { state: () => ({ id: 2, rawItems: [] as string[], diff --git a/packages/pinia/__tests__/pinia/stores/user.ts b/packages/pinia/__tests__/pinia/stores/user.ts index 64fab17e..963dedf4 100644 --- a/packages/pinia/__tests__/pinia/stores/user.ts +++ b/packages/pinia/__tests__/pinia/stores/user.ts @@ -5,8 +5,7 @@ function apiLogin(a: string, p: string) { return Promise.reject(new Error('invalid credentials')) } -export const useUserStore = defineStore({ - id: 'user', +export const useUserStore = defineStore('user', { state: () => ({ name: 'Eduardo', isAdmin: true,