Issue
I have a small util with a dedicated test file:
enqueue.js
enqueue.test.js
Later the util is imported into another module and used there:
However, when I run the single test for the enqueue.test.js
or for the whole project, Jest looks into the parent module that has no test suits and outputs the error for it:
ReferenceError: nn is not defined
37 |
38 | function init() {
> 39 | if (nn?.launch.allModulesInitialised) {
| ^
40 | return;
41 | }
42 |
… while the Jest config has a testRegexp property:
testRegex: '(/__tests__/.*|(\.|/)(test|spec))\.m?[jt]sx?$'
Files content

I have many other tests in the project that run well however this one fails, I suspect that it might have something to do with introducing web pack aliases to jest config:
{
verbose: true,
rootDir: rootPath,
transform: {}, // Disable default babel-jest transform to enable support for ES Modules
testRegex: '(/__tests__/.*|(\.|/)(test|spec))\.m?[jt]sx?$',
// testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
testEnvironment: 'jsdom',
modulePaths: [
'<rootDir>/build/node_modules',
],
moduleNameMapper: {
"^@common/(.*)$": "<rootDir>/src/js/common/js/$1",
"^@common.values": "<rootDir>/src/js/common/js/values",
"^@common.utils": "<rootDir>/src/js/common/js/utils",
},
};
… but still not sure what would be the reason of this behavior, did someone ever experience similar issue?