From a4f83ad1a24068be3f5d17e9ffba6b30ccf15e0e Mon Sep 17 00:00:00 2001 From: shrinktofit Date: Mon, 18 Sep 2023 11:42:45 +0800 Subject: [PATCH] Fix --- jest.config.js | 5 ++++- tests/init.ts | 9 +-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/jest.config.js b/jest.config.js index 269b4da88c6..1eb9d794173 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,7 +17,10 @@ module.exports = { // ignore everything in the node_modules EXCEPT for: // - @cocos/dragonbones-js 'node_modules/(?!(@cocos/dragonbones-js)/)', - 'native/external/emscripten/', + // ignore everything in the native/external/emscripten EXCEPT for: + // - meshopt + // Since above packages are in ESM module format, whereas we currently use CJS for testing. + 'native/external/emscripten/(?!(meshopt)/)', ], setupFilesAfterEnv: [ "./tests/setup-after-env.ts", diff --git a/tests/init.ts b/tests/init.ts index 83aec1ba28e..b9fb0d18057 100644 --- a/tests/init.ts +++ b/tests/init.ts @@ -81,6 +81,7 @@ jest.mock( 'external:emscripten/physx/physx.release.wasm.wasm', 'external:emscripten/spine/spine.wasm', 'external:emscripten/box2d/box2d.release.wasm.wasm', + 'external:emscripten/meshopt/meshopt_decoder.wasm.wasm', ].forEach(mockModuleId => { jest.mock(mockModuleId, () => ({ @@ -91,14 +92,6 @@ jest.mock( ); }); -jest.mock('external:emscripten/meshopt/meshopt_decoder.wasm.wasm', - () => ({ - __esModule: true, - default: 'this should be a wasm url', - }), - { virtual: true, }, -); - jest.mock('../cocos/core/platform/debug', () => { const result = { __esModule: true, // Use it when dealing with esModules