diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b399654913..ae724ef686cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +- `[jest-globals]` Export globals as values, not types ([#9925](https://github.com/facebook/jest/pull/9925)) + ### Chore & Maintenance ### Performance diff --git a/packages/jest-globals/src/index.ts b/packages/jest-globals/src/index.ts index 82bc15a3b522..cc13927c0d13 100644 --- a/packages/jest-globals/src/index.ts +++ b/packages/jest-globals/src/index.ts @@ -9,22 +9,22 @@ import importedExpect = require('expect'); import type {Jest} from '@jest/environment'; import type {Global} from '@jest/types'; -export declare type jest = Jest; +export declare const jest: Jest; -export declare type expect = typeof importedExpect; +export declare const expect: typeof importedExpect; -export declare type it = Global.GlobalAdditions['it']; -export declare type test = Global.GlobalAdditions['test']; -export declare type fit = Global.GlobalAdditions['fit']; -export declare type xit = Global.GlobalAdditions['xit']; -export declare type xtest = Global.GlobalAdditions['xtest']; -export declare type describe = Global.GlobalAdditions['describe']; -export declare type xdescribe = Global.GlobalAdditions['xdescribe']; -export declare type fdescribe = Global.GlobalAdditions['fdescribe']; -export declare type beforeAll = Global.GlobalAdditions['beforeAll']; -export declare type beforeEach = Global.GlobalAdditions['beforeEach']; -export declare type afterEach = Global.GlobalAdditions['afterEach']; -export declare type afterAll = Global.GlobalAdditions['afterAll']; +export declare const it: Global.GlobalAdditions['it']; +export declare const test: Global.GlobalAdditions['test']; +export declare const fit: Global.GlobalAdditions['fit']; +export declare const xit: Global.GlobalAdditions['xit']; +export declare const xtest: Global.GlobalAdditions['xtest']; +export declare const describe: Global.GlobalAdditions['describe']; +export declare const xdescribe: Global.GlobalAdditions['xdescribe']; +export declare const fdescribe: Global.GlobalAdditions['fdescribe']; +export declare const beforeAll: Global.GlobalAdditions['beforeAll']; +export declare const beforeEach: Global.GlobalAdditions['beforeEach']; +export declare const afterEach: Global.GlobalAdditions['afterEach']; +export declare const afterAll: Global.GlobalAdditions['afterAll']; throw new Error( 'Do not import `@jest/globals` outside of the Jest test environment', diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 609abc543ad2..32c1c751b7f1 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -54,8 +54,8 @@ import Snapshot = require('jest-snapshot'); import stripBOM = require('strip-bom'); interface JestGlobalsValues extends Global.TestFrameworkGlobals { - jest: JestGlobals.jest; - expect: JestGlobals.expect; + jest: typeof JestGlobals.jest; + expect: typeof JestGlobals.expect; } type HasteMapOptions = {