Skip to content

Migrate back to CommonJS export for jest-runtime #7608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jest-cli/src/__tests__/SearchSource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('SearchSource', () => {
let searchSource;

beforeEach(() => {
Runtime = require('jest-runtime').default;
Runtime = require('jest-runtime');
SearchSource = require('../SearchSource').default;
normalize = require('jest-config').normalize;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const cases = {
const filter = path => Object.keys(cases).every(key => cases[key](path));

beforeEach(() => {
Runtime = require('jest-runtime').default;
Runtime = require('jest-runtime');
config = normalize(
{
rootDir: '.',
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runner/src/runTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function runTestInternal(
const Runtime = ((config.moduleLoader
? /* $FlowFixMe */
require(config.moduleLoader)
: require('jest-runtime').default): Class<RuntimeClass>);
: require('jest-runtime')): Class<RuntimeClass>);

let runtime = undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/__mocks__/createRuntime.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import path from 'path';

module.exports = function createRuntime(filename, config) {
const NodeEnvironment = require('jest-environment-node');
const Runtime = require('../').default;
const Runtime = require('../');

const {normalize} = require('jest-config');

Expand Down
6 changes: 4 additions & 2 deletions packages/jest-runtime/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import yargs from 'yargs';
import {Console, setGlobal} from 'jest-util';
import {validateCLIOptions} from 'jest-validate';
import {readConfig, deprecationEntries} from 'jest-config';
// eslint-disable-next-line import/default
import Runtime from '../';
import * as args from './args';

const VERSION = (require('../../package.json').version: string);
Expand Down Expand Up @@ -75,6 +73,10 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {
automock: false,
unmockedModulePathPatterns: null,
});

// Break circular dependency
const Runtime = require('..');

Runtime.createContext(config, {
maxWorkers: Math.max(os.cpus().length - 1, 1),
watchman: globalConfig.watchman,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,4 +1017,4 @@ class Runtime {

Runtime.ScriptTransformer = ScriptTransformer;

export default Runtime;
module.exports = Runtime;