From ff208ca068904749030f8e807c5f231f3cfdc131 Mon Sep 17 00:00:00 2001 From: Zakary Date: Thu, 7 Jul 2022 15:57:31 +0800 Subject: [PATCH] fix(test): fix runtime moduleNameMapper --- packages/taro-mini-runner/jest.config.js | 3 +++ packages/taro-mini-runner/src/__tests__/utils/compiler.ts | 1 - packages/taro-webpack-runner/jest.config.js | 3 ++- packages/taro-webpack-runner/src/__tests__/utils/compiler.ts | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/taro-mini-runner/jest.config.js b/packages/taro-mini-runner/jest.config.js index 338ed12d98e1..d901d8930e19 100644 --- a/packages/taro-mini-runner/jest.config.js +++ b/packages/taro-mini-runner/jest.config.js @@ -8,6 +8,9 @@ module.exports = { } }, moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx', 'node'], + moduleNameMapper: { + '@tarojs/runtime': '/src/__tests__/mocks/taro-runtime', + }, preset: 'ts-jest', setupFilesAfterEnv: ['./src/__tests__/setup/index.ts'], testEnvironment: 'node', diff --git a/packages/taro-mini-runner/src/__tests__/utils/compiler.ts b/packages/taro-mini-runner/src/__tests__/utils/compiler.ts index 2cd753e5c3b3..0d5854c86fbb 100644 --- a/packages/taro-mini-runner/src/__tests__/utils/compiler.ts +++ b/packages/taro-mini-runner/src/__tests__/utils/compiler.ts @@ -60,7 +60,6 @@ export async function compile (app: string, customConfig: Partial chain.merge({ resolve: { alias: { - '@tarojs/runtime': path.resolve(__dirname, '../mocks/taro-runtime'), '@tarojs/components$': path.resolve(__dirname, '../mocks/taro-components'), '@tarojs/react': path.resolve(__dirname, '../mocks/taro-react'), '@tarojs/taro': path.resolve(__dirname, '../mocks/taro'), diff --git a/packages/taro-webpack-runner/jest.config.js b/packages/taro-webpack-runner/jest.config.js index 024e17512563..c544893b86cb 100644 --- a/packages/taro-webpack-runner/jest.config.js +++ b/packages/taro-webpack-runner/jest.config.js @@ -10,7 +10,8 @@ module.exports = { moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx', 'node'], moduleNameMapper: { '@pmmmwh/react-refresh-webpack-plugin': '/src/__tests__/mocks/react-refresh', - '@prefresh/webpack': '/src/__tests__/mocks/react-refresh' + '@prefresh/webpack': '/src/__tests__/mocks/react-refresh', + '@tarojs/runtime': '/src/__tests__/mocks/taro-runtime', }, preset: 'ts-jest', setupFilesAfterEnv: ['./src/__tests__/setup/index.ts'], diff --git a/packages/taro-webpack-runner/src/__tests__/utils/compiler.ts b/packages/taro-webpack-runner/src/__tests__/utils/compiler.ts index 189551f37585..5985fcad7aa6 100644 --- a/packages/taro-webpack-runner/src/__tests__/utils/compiler.ts +++ b/packages/taro-webpack-runner/src/__tests__/utils/compiler.ts @@ -119,7 +119,6 @@ export async function compile (app: string, customConfig: Partial = webpackChain.merge({ resolve: { alias: { - '@tarojs/runtime': path.resolve(__dirname, '../mocks/taro-runtime'), '@tarojs/shared': path.resolve(__dirname, '../mocks/taro-shared'), '@tarojs/taro-h5': path.resolve(__dirname, '../mocks/taro-h5'), '@tarojs/router': path.resolve(__dirname, '../mocks/taro-router'),