Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest test are failing with zipcelx #60

Closed
dmitry-urenev opened this issue May 24, 2019 · 1 comment
Closed

Jest test are failing with zipcelx #60

dmitry-urenev opened this issue May 24, 2019 · 1 comment

Comments

@dmitry-urenev
Copy link

Hi guys, great library, I have the following error. My jest tests are failing with following error:

Test suite failed to run

    /node_modules/zipcelx/lib/module.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import escape from 'lodash.escape';
                                                                                                    ^^^^^^

    SyntaxError: Unexpected identifier

      1 | ....
    > 2 | import zipcelx, { ZipCelXCell, ZipCelXConfig, ZipCelXRow } from 'zipcelx';
        | ^

My setup: Angular 7 + Jest + zipcelx
package.json with all required dependencies for zipcelx and jest config looks like this:

dependencies: {
    ...
    "zipcelx": "^1.6.0",
    "jszip": "^3.1.3",
    "lodash.escape": "^4.0.1",
    "stream": "^0.0.2"
},
 "jest": {
    "verbose": true,
    "testURL": "http://localhost/",
    "preset": "jest-preset-angular",
    "setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts",
    "transformIgnorePatterns": [
      "node_modules/(?!@ngrx)"
    ],
    "transform": {
      "^.+\\.(ts|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js",
      "^.+\\.js$": "babel-jest"
    }
}

The interesting thing is that the production build/serve works nice. Also when I ran it with ng serve everything worked and it produced the correct xlsx file, which would solve all my problems. Only tests are failing. Any ideas what I might be missing?

@dmitry-urenev
Copy link
Author

resolved by adding zipcelx to transformIgnorePatterns config:

"jest": {
    "verbose": true,
    "testURL": "http://localhost/",
    "preset": "jest-preset-angular",
    "setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts",
    "transformIgnorePatterns": [
      "node_modules/(?!@ngrx|zipcelx)"
    ],
    "transform": {
      "^.+\\.(ts|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js",
      "^.+\\.js$": "babel-jest"
    }
}

Related issues: jestjs/jest#2081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant