3.0.1 doesn't work with Jest
See original GitHub issueWhen 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:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed it. Just had to move the jest config into package.json:
Yes. Please check if the Jest section in https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c answers the use case? (linked from https://github.com/d3/d3-interpolate/releases/tag/v3.0.0).