Closed dragansmlinus closed 2 years ago
Fixed it by:
module.exports = {
moduleNameMapper: {
"^components/(.*)": "<rootDir>/src/components/$1",
"^hooks/(.*)": "<rootDir>/src/hooks/$1",
"^types/(.*)": "<rootDir>/src/types/$1",
"^utils/(.*)": "<rootDir>/src/utils/$1",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/jest/fileMock.js",
"\\.(css|less)$": "<rootDir>/jest/styleMock.js"
},
transformIgnorePatterns: [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$",
"^.+\\.js$",
],
};
// src/jest/fileMock.js
module.exports = 'test-file-stub';
// src/jest/styleMock.js
module.exports = {};
Refs:
Current Behavior
I've added
.babelrc
and
jest.config.js
file in order to override the defaultmoduleNameMapper
(tsdx provides here[]
)Running the test (
tsdx test --passWithNoTests
) returnstsconfig.json