Skip to content

Commit

Permalink
re-add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 16, 2025
1 parent ad5a6d2 commit 1b6d54f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions packages/jest-runtime/src/__tests__/runtime_wrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* 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.
*
*/

let createRuntime;

describe('Runtime', () => {
beforeEach(() => {
createRuntime = require('createRuntime');
});

describe('constructInjectedModuleParameters', () => {
it('generates the correct args', async () => {
const runtime = await createRuntime(__filename);

expect(runtime.constructInjectedModuleParameters()).toEqual([
'module',
'exports',
'require',
'__dirname',
'__filename',
'jest',
]);
});

it('injects "extra globals"', async () => {
const runtime = await createRuntime(__filename, {
sandboxInjectedGlobals: ['Math'],
});

expect(runtime.constructInjectedModuleParameters()).toEqual([
'module',
'exports',
'require',
'__dirname',
'__filename',
'jest',
'Math',
]);
});

it('avoid injecting `jest` if `injectGlobals = false`', async () => {
const runtime = await createRuntime(__filename, {
injectGlobals: false,
});

expect(runtime.constructInjectedModuleParameters()).toEqual([
'module',
'exports',
'require',
'__dirname',
'__filename',
]);
});
});
});

0 comments on commit 1b6d54f

Please sign in to comment.