From 81e15834c2016a625c8d48b31aab3173cb2a949d Mon Sep 17 00:00:00 2001 From: Amour1688 Date: Thu, 1 Oct 2020 20:56:26 +0800 Subject: [PATCH] chore: ts-jest --- .jest.js | 8 +++++++- components/{index.ts => index.js} | 0 package.json | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) rename components/{index.ts => index.js} (100%) diff --git a/.jest.js b/.jest.js index d35db6229..24c57d146 100644 --- a/.jest.js +++ b/.jest.js @@ -13,12 +13,13 @@ if (process.env.WORKFLOW === 'true') { module.exports = { testURL: 'http://localhost/', setupFiles: ['./tests/setup.js'], - moduleFileExtensions: ['js', 'jsx', 'json', 'vue', 'md', 'jpg'], + moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue', 'md', 'jpg'], modulePathIgnorePatterns: ['/_site/'], testPathIgnorePatterns: testPathIgnorePatterns, transform: { '^.+\\.(vue|md)$': '/node_modules/vue-jest', '^.+\\.(js|jsx)$': '/node_modules/babel-jest', + '^.+\\.(ts|tsx)$': '/node_modules/ts-jest', '^.+\\.svg$': '/node_modules/jest-transform-stub', }, testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$', @@ -45,4 +46,9 @@ module.exports = { ], testEnvironment: 'jest-environment-jsdom-fifteen', transformIgnorePatterns, + globals: { + 'ts-jest': { + babelConfig: true, + }, + }, }; diff --git a/components/index.ts b/components/index.js similarity index 100% rename from components/index.ts rename to components/index.js diff --git a/package.json b/package.json index 4ab392e1b..cfe164656 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "html-webpack-plugin": "^3.2.0", "husky": "^4.0.0", "istanbul-instrumenter-loader": "^3.0.0", - "jest": "^25.4.0", + "jest": "^26.0.0", "jest-environment-jsdom-fifteen": "^1.0.2", "jest-serializer-vue": "^2.0.0", "jest-transform-stub": "^2.0.0", @@ -168,6 +168,7 @@ "stylelint-config-standard": "^19.0.0", "terser-webpack-plugin": "^3.0.3", "through2": "^3.0.0", + "ts-jest": "^26.4.1", "ts-loader": "^8.0.2", "typescript": "^4.0.2", "umi-mock-middleware": "^1.0.0",