Skip to content

Commit

Permalink
fix(jest-snapshot): Avoid importing Babel inside sandbox (#13694)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersk committed Jan 1, 2023
1 parent 0b27bbb commit 8709b7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
- `[jest-environment-node]` fix non-configurable globals ([#13687](https://github.com/facebook/jest/pull/13687))
- `[@jest/expect-utils]` `toMatchObject` should handle `Symbol` properties ([#13639](https://github.com/facebook/jest/pull/13639))
- `[jest-resolve]` Add global paths to `require.resolve.paths` ([#13633](https://github.com/facebook/jest/pull/13633))
- `[jest-snapshot]` Make sure to import `babel` outside of the sandbox ([#13694](https://github.com/facebook/jest/pull/13694))

### Chore & Maintenance

Expand Down
9 changes: 4 additions & 5 deletions packages/jest-snapshot/src/InlineSnapshots.ts
Expand Up @@ -7,7 +7,7 @@

import * as path from 'path';
import type {ParseResult, PluginItem} from '@babel/core';
import {Expression, File, Program, isAwaitExpression} from '@babel/types';
import type {Expression, File, Program} from '@babel/types';
import * as fs from 'graceful-fs';
import type {
CustomParser as PrettierCustomParser,
Expand All @@ -27,10 +27,9 @@ const generate = (
// @ts-expect-error requireOutside Babel transform
requireOutside('@babel/generator') as typeof import('@babel/generator')
).default;
// @ts-expect-error requireOutside Babel transform
const {file, templateElement, templateLiteral} = requireOutside(
'@babel/types',
) as typeof import('@babel/types');
const {file, isAwaitExpression, templateElement, templateLiteral} =
// @ts-expect-error requireOutside Babel transform
requireOutside('@babel/types') as typeof import('@babel/types');
// @ts-expect-error requireOutside Babel transform
const {parseSync} = requireOutside(
'@babel/core',
Expand Down

0 comments on commit 8709b7d

Please sign in to comment.