forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "feat: add
@jest/globals
package for importing globa…
…ls explicitly (jestjs#9801)"" This reverts commit 75ab1ab.
- Loading branch information
Showing
15 changed files
with
195 additions
and
10 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
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
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
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,13 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import runJest from '../runJest'; | ||
|
||
test('imported globals', () => { | ||
const result = runJest('imported-globals'); | ||
expect(result.exitCode).toBe(0); | ||
}); |
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,22 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { | ||
expect as importedExpect, | ||
jest as importedJest, | ||
test as importedTest, | ||
} from '@jest/globals'; | ||
|
||
importedTest('they match the globals', () => { | ||
importedExpect(importedExpect).toBe(expect); | ||
importedExpect(importedJest).toBe(jest); | ||
importedExpect(importedTest).toBe(test); | ||
|
||
expect(importedExpect).toBe(expect); | ||
expect(importedJest).toBe(jest); | ||
expect(importedTest).toBe(test); | ||
}); |
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,8 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = require('../../babel.config'); |
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,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
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,5 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
src | ||
tsconfig.json | ||
tsconfig.tsbuildinfo |
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,30 @@ | ||
{ | ||
"name": "@jest/globals", | ||
"version": "25.4.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git", | ||
"directory": "packages/jest-globals" | ||
}, | ||
"engines": { | ||
"node": ">= 8.3" | ||
}, | ||
"license": "MIT", | ||
"main": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"typesVersions": { | ||
"<3.8": { | ||
"build/*": [ | ||
"build/ts3.4/*" | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"@jest/environment": "^25.4.0", | ||
"@jest/types": "^25.4.0", | ||
"expect": "^25.4.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,12 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
test('throw when directly imported', () => { | ||
expect(() => require('../')).toThrowError( | ||
'Do not import `@jest/globals` outside of the Jest test environment', | ||
); | ||
}); |
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,31 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import importedExpect = require('expect'); | ||
import type {Jest} from '@jest/environment'; | ||
import type {Global} from '@jest/types'; | ||
|
||
export declare type jest = Jest; | ||
|
||
export declare type 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']; | ||
|
||
throw new Error( | ||
'Do not import `@jest/globals` outside of the Jest test environment', | ||
); |
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,14 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
// we don't want `@types/jest` to be referenced | ||
"types": ["node"], | ||
"rootDir": "src", | ||
"outDir": "build" | ||
}, | ||
"references": [ | ||
{"path": "../expect"}, | ||
{"path": "../jest-environment"}, | ||
{"path": "../jest-types"} | ||
] | ||
} |
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
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
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