diff --git a/packages/jest-console/src/BufferedConsole.ts b/packages/jest-console/src/BufferedConsole.ts index 73dc05fd5c1e..c670f6d4a698 100644 --- a/packages/jest-console/src/BufferedConsole.ts +++ b/packages/jest-console/src/BufferedConsole.ts @@ -7,7 +7,7 @@ import assert = require('assert'); import {Console} from 'console'; -import {format, formatWithOptions, inspect, InspectOptions} from 'util'; +import {InspectOptions, format, formatWithOptions, inspect} from 'util'; import chalk = require('chalk'); import {ErrorWithStack, formatTime} from 'jest-util'; import type { diff --git a/packages/jest-console/src/CustomConsole.ts b/packages/jest-console/src/CustomConsole.ts index 4e8207a3cf13..7c8009ad1159 100644 --- a/packages/jest-console/src/CustomConsole.ts +++ b/packages/jest-console/src/CustomConsole.ts @@ -7,7 +7,7 @@ import assert = require('assert'); import {Console} from 'console'; -import {format, formatWithOptions, inspect, InspectOptions} from 'util'; +import {InspectOptions, format, formatWithOptions, inspect} from 'util'; import chalk = require('chalk'); import {clearLine, formatTime} from 'jest-util'; import type {LogCounters, LogMessage, LogTimers, LogType} from './types'; diff --git a/packages/jest-each/src/index.ts b/packages/jest-each/src/index.ts index 68101222872c..2d786f29d8c0 100644 --- a/packages/jest-each/src/index.ts +++ b/packages/jest-each/src/index.ts @@ -68,7 +68,8 @@ const install = ( const each = ( table: Global.EachTable, ...data: Global.TemplateData -): ReturnType => install(global as unknown as typeof globalThis, table, ...data); +): ReturnType => + install(global as unknown as typeof globalThis, table, ...data); each.withGlobal = (g: typeof globalThis) => diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts index 413ac3971a73..1b6ae6c3ac5e 100644 --- a/packages/jest-environment-jsdom/src/index.ts +++ b/packages/jest-environment-jsdom/src/index.ts @@ -105,7 +105,10 @@ class JSDOMEnvironment implements JestEnvironment { timerConfig, }); - this.fakeTimersModern = new ModernFakeTimers({config, global: global as any as typeof globalThis}); + this.fakeTimersModern = new ModernFakeTimers({ + config, + global: global as any as typeof globalThis, + }); } async setup(): Promise {} diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 6c85ee041e58..4ce75ea2303b 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -32,10 +32,10 @@ export type ModuleWrapper = ( ...extraGlobals: Array ) => unknown; -export declare class JestEnvironment { +export declare class JestEnvironment { constructor(config: Config.ProjectConfig, context?: EnvironmentContext); global: Global.Global; - fakeTimers: LegacyFakeTimers | null; + fakeTimers: LegacyFakeTimers | null; fakeTimersModern: ModernFakeTimers | null; moduleMocker: ModuleMocker | null; getVmContext(): Context | null; diff --git a/packages/jest-jasmine2/src/jasmine/Env.ts b/packages/jest-jasmine2/src/jasmine/Env.ts index d7ad4c7efca8..fccc7df35980 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.ts +++ b/packages/jest-jasmine2/src/jasmine/Env.ts @@ -104,8 +104,10 @@ export default function (j$: Jasmine) { let catchExceptions = true; - const realSetTimeout = global.setTimeout as typeof globalThis['setTimeout']; - const realClearTimeout = global.clearTimeout as typeof globalThis['clearTimeout']; + const realSetTimeout = + global.setTimeout as typeof globalThis['setTimeout']; + const realClearTimeout = + global.clearTimeout as typeof globalThis['clearTimeout']; const runnableResources: Record}> = {}; const currentlyExecutingSuites: Array = []; diff --git a/packages/jest-jasmine2/src/types.ts b/packages/jest-jasmine2/src/types.ts index 76714af82e48..bc131dedaf56 100644 --- a/packages/jest-jasmine2/src/types.ts +++ b/packages/jest-jasmine2/src/types.ts @@ -89,7 +89,8 @@ export type Jasmine = { version: string; testPath: Config.Path; addMatchers: (matchers: JasmineMatchersObject) => void; -} & typeof expect & typeof globalThis; +} & typeof expect & + typeof globalThis; declare global { module NodeJS { diff --git a/packages/jest-repl/src/cli/runtime-cli.ts b/packages/jest-repl/src/cli/runtime-cli.ts index 0067b47414bc..619b77daf8b9 100644 --- a/packages/jest-repl/src/cli/runtime-cli.ts +++ b/packages/jest-repl/src/cli/runtime-cli.ts @@ -84,8 +84,16 @@ export async function run( 'console', new CustomConsole(process.stdout, process.stderr), ); - setGlobal(environment.global as unknown as typeof globalThis, 'jestProjectConfig', config); - setGlobal(environment.global as unknown as typeof globalThis, 'jestGlobalConfig', globalConfig); + setGlobal( + environment.global as unknown as typeof globalThis, + 'jestProjectConfig', + config, + ); + setGlobal( + environment.global as unknown as typeof globalThis, + 'jestGlobalConfig', + globalConfig, + ); const runtime = new Runtime( config, diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 4d488bf8011c..cd855860a98a 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -156,7 +156,11 @@ async function runTestInternal( ? new LeakDetector(environment) : null; - setGlobal(environment.global as unknown as typeof globalThis, 'console', testConsole); + setGlobal( + environment.global as unknown as typeof globalThis, + 'console', + testConsole, + ); const runtime = new Runtime( config, diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index edef2916fe43..26387c639e3e 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -929,16 +929,18 @@ export default class Runtime { if (this._environment) { if (this._environment.global) { const envGlobal = this._environment.global; - (Object.keys(envGlobal) as Array).forEach(key => { - const globalMock = envGlobal[key]; - if ( - ((typeof globalMock === 'object' && globalMock !== null) || - typeof globalMock === 'function') && - globalMock._isMockFunction === true - ) { - globalMock.mockClear(); - } - }); + (Object.keys(envGlobal) as Array).forEach( + key => { + const globalMock = envGlobal[key]; + if ( + ((typeof globalMock === 'object' && globalMock !== null) || + typeof globalMock === 'function') && + globalMock._isMockFunction === true + ) { + globalMock.mockClear(); + } + }, + ); } if (this._environment.fakeTimers) {