Reputation: 251
I have a test failing with the error Unexpected token 'export'
due to code imported from swiper
package, I added node_modules to transformIgnorePatterns in my config but that is not working. Configs below:
"jest": {
"watchPathIgnorePatterns": [
"node_modules",
".jest-test-results.json"
],
"transformIgnorePatterns": [
"node_modules"
],
"moduleNameMapper": {
"\\.(css)$": "<rootDir>/test/jest/__mocks__/styleMock.js",
"<rootDir>/node_modules/swiper/core/core.js": "<rootDir>/test/jest/__mocks__/styleMock.js"
}
}
Upvotes: 4
Views: 1262
Reputation: 251
Issue was that I wasn't specifying packages in trasnformIgnorePatterns. Following works:
"transformIgnorePatterns": [
"/node_modules/(?!(swiper|ssr-window|dom7))"
],
Upvotes: 1