From 149502db847a9ef96d2dea4d4bfc4a5ad9ba70e6 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Thu, 3 Dec 2020 11:55:05 +0100 Subject: [PATCH] fix(babel-plugin-jest-hoist): allow using module wrapper arguments in hoisted mock factory function (#10903) --- CHANGELOG.md | 1 + packages/babel-plugin-jest-hoist/src/index.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfcd11c21f09..56a87a6ec150 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Fixes +- `[babel-plugin-jest-hoist]` Add `__dirname` and `__filename` to whitelisted globals ([#10903](https://github.com/facebook/jest/pull/10903)) - `[expect]` [**BREAKING**] Revise `expect.not.objectContaining()` to be the inverse of `expect.objectContaining()`, as documented. ([#10708](https://github.com/facebook/jest/pull/10708)) - `[jest-circus]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block [#10451](https://github.com/facebook/jest/issues/10451) - `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871)) diff --git a/packages/babel-plugin-jest-hoist/src/index.ts b/packages/babel-plugin-jest-hoist/src/index.ts index f5c59c44de25..d35602e68d5c 100644 --- a/packages/babel-plugin-jest-hoist/src/index.ts +++ b/packages/babel-plugin-jest-hoist/src/index.ts @@ -85,7 +85,11 @@ const ALLOWED_IDENTIFIERS = new Set( 'jest', 'parseFloat', 'parseInt', + 'exports', 'require', + 'module', + '__filename', + '__dirname', 'undefined', ...Object.getOwnPropertyNames(global), ].sort(),