From e4266ac70a783d4b07915930c42f93f48150973f Mon Sep 17 00:00:00 2001 From: pikax Date: Mon, 27 Apr 2020 13:10:05 +0100 Subject: [PATCH 1/3] feat: run test using build file --- jest.config.js | 4 +++- package.json | 1 + setup.js | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jest.config.js b/jest.config.js index 64079a0d7..dff0697d7 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,8 @@ module.exports = { preset: 'ts-jest', - globals: {}, + globals: { + __USE_BUILD__: process.argv.indexOf('-use-build') >= 0 + }, testEnvironment: 'jsdom', transform: { "^.+\\.vue$": "vue-jest", diff --git a/package.json b/package.json index c42dcfaa5..5b78d3eaf 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ }, "scripts": { "test": "yarn jest --runInBand tests", + "test:build": "yarn jest --runInBand tests --use-build", "tsd": "tsd", "build": "yarn rollup -c rollup.config.js", "lint": "prettier -c --parser typescript \"(src|tests)/**/*.ts?(x)\"", diff --git a/setup.js b/setup.js index cbc44511d..fa8fc5156 100644 --- a/setup.js +++ b/setup.js @@ -10,4 +10,8 @@ console.info = (...args) => { } originalConsole(...args) -} \ No newline at end of file +} + +if (__USE_BUILD__) { + jest.mock('./src', () => jest.requireActual('./dist/vue-test-utils.cjs')) +} From e0c70456aacdac8856166e32c1f3f18845262d5a Mon Sep 17 00:00:00 2001 From: pikax Date: Mon, 27 Apr 2020 14:41:02 +0100 Subject: [PATCH 2/3] fix: package script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b78d3eaf..ac17fa1ba 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ }, "scripts": { "test": "yarn jest --runInBand tests", - "test:build": "yarn jest --runInBand tests --use-build", + "test:build": "yarn jest --runInBand tests -use-build", "tsd": "tsd", "build": "yarn rollup -c rollup.config.js", "lint": "prettier -c --parser typescript \"(src|tests)/**/*.ts?(x)\"", From 9c4e8df59019f73992eff0d0f8cf3b0484e7e2d4 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Mon, 27 Apr 2020 14:54:03 +0100 Subject: [PATCH 3/3] build: add test to ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ad17a8c8..9fd679533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,4 +30,5 @@ jobs: - run: yarn build env: CI: true + - run: yarn test:build - run: yarn tsd