3.0.1 doesn't work with Jest

See original GitHub issue

When trying to upgrade d3-interpolate 2.0.1 -> 3.0.1, my Jest tests fail with:

  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /home/slaweet/git/frontend/node_modules/d3-interpolate/src/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export {default as interpolate} from "./value.js";
                                                                                             ^^^^^^

    SyntaxError: Unexpected token 'export'

      129 | <script lang="ts">
      130 | import { Component, Prop, Vue } from 'vue-property-decorator';
    > 131 | import { interpolateRgb } from 'd3-interpolate';
          | ^
      132 | import BigNumber from 'bignumber.js';
      133 | import { Stats } from 'fast-stats';
      134 | import Color from 'color';

Using node v14.15.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
jbolercommented, Jul 23, 2021

Fixed it. Just had to move the jest config into package.json:

  "jest": {
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/(?!d3)/"
    ]
  },
2reactions
Filcommented, Jun 7, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure jest with latest version of d3-path - Stack Overflow
For some reason, my jest configuration doesn't work with the latest version of d3-path@3.0.1 . It worked fine with version 2.0.0 .
Read more >
jest-runner-vscode - npm
Tests are run sequentially. A single instance of VS Code is launched for each unique directory containing tests. This allows you to save...
Read more >
Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
Get rid of "Unresolved function/method/variable" warning in ...
Same issue here, only the 'expect' keyword is not recognized. When I try to download jest via Languages & Frameworks | JavaScript |...
Read more >
jest-fail-on-console | Yarn - Package Manager
What problem is this solving? Jest doesn't fail the tests when there is a console.error . In large codebase, we can end up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found