import { version } from "package.json"; - in Jest
Add your test
environment to your .babelrc
in the root of your project:
{
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
After that, Jest is able to process this:
import { version } from "package.json";