I'm trying to write some tests for some modules that happen to import an openlayers module or two. But as some others have found (here, here, and here), this doesn't work out of the box. Here's what I've tried:
- renaming
.babelrc
tobabel.config.js
and exporting the config - added
transformIgnorePatterns
to myjest.config.js
I'm just at a loss as to what would fix this now.
I'm using:
- Non-CRA webpack config
- Jest v23.6.0
- babel-core 6.26.3
- typescript 3.1.3
- ts-jest 22.4.6
Here's my configs:
Jest:
module.exports = {
setupFiles: [
"./testConfig/test-shim.js",
"./testConfig/test-setup.js"
],
transform: {
"^.+\\.tsx?$": "ts-jest"
},
transformIgnorePatterns: [
"/node_modules/(?!(ol)/).*/",
"node_modules/(?!(ol)/)",
],
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx|tsx?)$",
moduleNameMapper: {
"^(Controllers|Api|Utilities)/(.*)$": "<rootDir>Scripts/$1/$2"
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
coverageReporters: ["text", "text-summary", "html"],
coverageDirectory: "testConfig/coverageReport",
collectCoverageFrom: ["**/Scripts/{App,Controllers,Utilities,Localization,EntryPoints}/**/*.{ts,tsx}"],
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0
}
}
};