DLateef
DLateef

Reputation: 251

Jest test fails SyntaxError, unexpected token Export

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"
    }
}

enter image description here

Upvotes: 4

Views: 1262

Answers (1)

DLateef
DLateef

Reputation: 251

Issue was that I wasn't specifying packages in trasnformIgnorePatterns. Following works:

"transformIgnorePatterns": [
            "/node_modules/(?!(swiper|ssr-window|dom7))"
        ],

Upvotes: 1

Related Questions