From: Eduardo San Martin Morote Date: Thu, 19 Aug 2021 12:34:12 +0000 (+0200) Subject: feat(testing): add testing package X-Git-Tag: @pinia/nuxt@0.0.1~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc053763752c2b11d7b851f95334034a1f9b8347;p=thirdparty%2Fvuejs%2Fpinia.git feat(testing): add testing package --- diff --git a/jest.config.js b/jest.config.js index c4647470..172e759d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,11 @@ module.exports = { collectCoverage: true, coverageDirectory: 'coverage', coverageReporters: ['html', 'lcov', 'text'], - collectCoverageFrom: ['packages/pinia/src/**/*.ts'], + collectCoverageFrom: [ + 'packages/pinia/src/**/*.ts', + 'packages/testing/src/**/*.ts', + '!packages/testing/**/*.spec.ts', + ], coveragePathIgnorePatterns: [ '/node_modules/', 'src/index.ts', @@ -13,7 +17,10 @@ module.exports = { 'src/deprecated.ts', 'src/vue2-plugin.ts', ], - testMatch: ['/packages/pinia/__tests__/**/*.spec.ts'], + testMatch: [ + '/packages/pinia/__tests__/**/*.spec.ts', + '/packages/testing/**/*.spec.ts', + ], transform: { '^.+\\.tsx?$': '@sucrase/jest-plugin', }, diff --git a/packages/pinia/src/index.ts b/packages/pinia/src/index.ts index e0f8af46..73305dd8 100644 --- a/packages/pinia/src/index.ts +++ b/packages/pinia/src/index.ts @@ -59,9 +59,6 @@ export type { _StoreObject, } from './mapHelpers' -export { createTestingPinia } from './testing' -export type { TestingOptions, TestingPinia } from './testing' - export { acceptHMRUpdate } from './hmr' export { PiniaPlugin } from './vue2-plugin' diff --git a/packages/testing/README.md b/packages/testing/README.md new file mode 100644 index 00000000..f2cacbd8 --- /dev/null +++ b/packages/testing/README.md @@ -0,0 +1 @@ +# Pinia testing module diff --git a/packages/testing/package.json b/packages/testing/package.json new file mode 100644 index 00000000..a13506aa --- /dev/null +++ b/packages/testing/package.json @@ -0,0 +1,53 @@ +{ + "name": "@pinia/testing", + "version": "0.0.0", + "description": "Testing module for Pinia", + "keywords": [ + "vue", + "vuex", + "store", + "pinia", + "tests", + "mock", + "testing" + ], + "homepage": "https://github.com/posva/pinia/tree/v2/packages/testing#readme", + "bugs": { + "url": "https://github.com/posva/pinia/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/posva/pinia.git" + }, + "funding": "https://github.com/sponsors/posva", + "license": "MIT", + "author": { + "name": "Eduardo San Martin Morote", + "email": "posva13@gmail.com" + }, + "sideEffects": false, + "exports": { + "require": "./dist/index.js", + "import": "./dist/index.mjs" + }, + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "files": [ + "dist/*.js", + "dist/*.mjs", + "dist/*.d.ts", + "templates/*.js" + ], + "scripts": { + "build": "siroc", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l @pinia/testing -r 1" + }, + "dependencies": {}, + "devDependencies": { + "siroc": "^0.15.0" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts new file mode 100644 index 00000000..b5d8a91b --- /dev/null +++ b/packages/testing/src/index.ts @@ -0,0 +1,2 @@ +export { createTestingPinia } from './testing' +export type { TestingPinia, TestingOptions } from './testing' diff --git a/packages/pinia/__tests__/testing.spec.ts b/packages/testing/src/testing.spec.ts similarity index 96% rename from packages/pinia/__tests__/testing.spec.ts rename to packages/testing/src/testing.spec.ts index 0f97b3df..04dd6f7f 100644 --- a/packages/pinia/__tests__/testing.spec.ts +++ b/packages/testing/src/testing.spec.ts @@ -1,15 +1,10 @@ -import { - createPinia, - createTestingPinia, - defineStore, - TestingOptions, -} from '../src' +import { createTestingPinia, TestingOptions } from './testing' +import { createPinia, defineStore } from 'pinia' import { mount } from '@vue/test-utils' import { defineComponent } from 'vue' describe('Testing', () => { - const useCounter = defineStore({ - id: 'counter', + const useCounter = defineStore('counter', { state: () => ({ n: 0 }), actions: { increment(amount = 1) { diff --git a/packages/pinia/src/testing.ts b/packages/testing/src/testing.ts similarity index 96% rename from packages/pinia/src/testing.ts rename to packages/testing/src/testing.ts index ffdf61be..39789d5a 100644 --- a/packages/pinia/src/testing.ts +++ b/packages/testing/src/testing.ts @@ -1,6 +1,10 @@ import { App, createApp } from 'vue-demi' -import { createPinia } from './createPinia' -import { Pinia, PiniaStorePlugin, setActivePinia } from './rootStore' +import { createPinia } from 'pinia' +import { + Pinia, + PiniaStorePlugin, + setActivePinia, +} from '../../pinia/src/rootStore' export interface TestingOptions { /**