Using any of the modules provided my core-js/packages returns this error. Jest targets the old structure of core-js

yarn add core-js -DdefineStack.js
const defineStack = (stack) => {
// Converting the exisiting string trace into an array
stack = stack.split('\n');
// Removing the first 2 elements of the array
for (let i = 0; i < 3; ++i) {
stack.shift();
}
// Returning the value of this.stack to the required stack trace
return stack.join('\n').trim();
}
export default defineStack;
__tests__/defineStack.js
import defineStack from '../defineStack';
test('trims the stack and returns proper information', () => {
console.log(defineStack);
});
The tests should pass and log the function definition
npx envinfo --preset jest System:
OS: macOS 10.14.4
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 10.15.0 - /usr/local/bin/node
Yarn: 1.16.0 - ~/.yarn/bin/yarn
npm: 6.9.0 - ~/.npm-packages/bin/npm
npmPackages:
jest: ^24.8.0 => 24.8.0
According to the change log of core-js v3.0
Move all features from ES5, ES2015, ES2016, ES2017, ES2018 and ES2019 to one namespace for stable ES - it's available as core-js/es, all those features in modules folder has es. prefix.
Change prefix for ES proposals from es7. to esnext., they no longer available in core-js/es7, use core-js/stage/* instead of that.
Downgrading it to v2.6.5 solves my tests issue, but I want to keep the dependency up to date for compatibility with other packages.
@AmaanKulshreshtha Babel currently assumes you are using corejs@2. You should be able to add corejs: 3 to your @babel/preset-env options to fix this 馃槂
e.g.
{
presets: [
[
'@babel/env',
{
targets: {
// ...
},
useBuiltIns: 'usage',
corejs: 3
}
]
}
The solution works....thanks so much!!
Although I would like to know how does jest work with babel, I haven't installed the babel-jest package....? 馃
Strange, not particularly familiar with Jest internals so can't comment on that. Perhaps create a minimal repro for one of the maintainers to look at assuming this isn't expected behaviour.
Not sure how long it's been this way (a long time I think), but Jest comes with babel-jest in the dependency tree and it is preconfigured as a transform. Not sure if there's a reason we still recommend installing babel-jest explicitly in places in the docs @SimenB
We need babel to have test coverage and mocks, which is why it's on by default.
You need it to live at the top level of node_modules. It being hoisted by the package manager is an implementation detail.
Jest has bundled babel-jest for ~10 versions
That said, this issue is about babel configuration, it's not an issue with Jest.
I have the same issue now and I've been searching for two days.

Seems that jest.mock not working.

I've installed babel-jest as dev-depen and core-js 3.0 as dependency.
Hope you guys could check this out. I would appreciate very much.
Most helpful comment
@AmaanKulshreshtha Babel currently assumes you are using corejs@2. You should be able to add
corejs: 3to your@babel/preset-envoptions to fix this 馃槂e.g.