After @babel/core@^7.6.0, v8intrinsic is supported to be parsed via babel, but run it with node requires a flag --allow-natives-syntax.
We are using node --allow-natives-syntax node_modules/.bin/jest here
When using it inside a jest unit test, jest-runner is not able to recognize % which used to call v8intrinsic.
Like below:
describe('foo', () => {
beforeEach(async () => {
await page.goto(PATH, { waitUntil: 'load' })
})
test('should return bar', async () => {
const foo = await page.evaluate(() => {
console.log('foo');
var args = 'testing';
%GetOptimizationStatus(args);
return foo(args);
})
expect(foo).toBe('bar')
})
})
Are you enabling the "v8intrinsic"
Babel plugin?
See here for details: https://babeljs.io/blog/2019/09/05/7.6.0#v8-intrinsic-runtime-functions-parsing-10148httpsgithubcombabelbabelpull10148
(Note that I wouldn't recommend to rely on V8 intrinsics for anything, not even tests. Especially something like %GetOptimizationStatus
is an internal detail that can and will change over time. If I were in your (or your team's) place, I wouldn't want to have to debug failing tests just because a new V8 version does some internal stuff slightly differently from before. But of course that's up to you...)