-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/jest-runtime/src/__tests__/runtime_resetModules_unsafe_global_proxy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
let createRuntime; | ||
|
||
describe('Runtime', () => { | ||
beforeEach(() => { | ||
createRuntime = require('createRuntime'); | ||
}); | ||
|
||
describe('resetModules', () => { | ||
it('does not throw when accessing _isMockFunction on an unsafe global', async () => { | ||
const runtime = await createRuntime(__filename); | ||
runtime._environment.global.UNSAFE_GLOBAL = new Proxy( | ||
{}, | ||
{ | ||
get(target, p, receiver) { | ||
if (p === '_isMockFunction') throw new Error('Unsafe global!'); | ||
}, | ||
}, | ||
); | ||
expect(() => runtime.resetModules()).not.toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters