Skip to content
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

chore: replace @types/jest with a new private @jest/test-globals package #13344

Merged
merged 15 commits into from
Oct 1, 2022
24 changes: 5 additions & 19 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,

"target": "es2017",
"module": "commonjs",
"lib": ["dom", "es2017"],
"strict": true,

/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,

/* Module Resolution Options */
"moduleResolution": "node",
"isolatedModules": true,
"importsNotUsedAsValues": "error",
"resolveJsonModule": true
}
"composite": false,
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
2 changes: 1 addition & 1 deletion examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@babel/plugin-proposal-decorators": "*",
"@babel/preset-env": "^7.1.0",
"@babel/preset-typescript": "^7.0.0",
"@types/jest": "^27.4.0",
"@jest/globals": "workspace:^",
"babel-jest": "workspace:^",
"babel-plugin-transform-typescript-metadata": "*",
"jest": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions examples/typescript/__tests__/CheckboxWithLabel-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import * as React from 'react';
import * as TestUtils from 'react-dom/test-utils';
import {expect, it} from '@jest/globals';

const CheckboxWithLabel = require('../CheckboxWithLabel').default;

Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/__tests__/calc.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

import {jest} from '@jest/globals';
import {describe, expect, it, jest} from '@jest/globals';

import Memory from '../memory';
import sub from '../sub';
Expand Down
1 change: 1 addition & 0 deletions examples/typescript/__tests__/sub-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

import sub from '../sub';
import {expect, it} from '@jest/globals';

it('subtracts 5 - 1 to equal 4 in TypeScript', () => {
expect(sub(5, 1)).toBe(4);
Expand Down
2 changes: 2 additions & 0 deletions examples/typescript/__tests__/sum-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

import {expect, it} from '@jest/globals';

it('adds 1 + 2 to equal 3 in TScript', () => {
// Generally, `import` should be used for TypeScript
// as using `require` will not return any type information.
Expand Down
2 changes: 2 additions & 0 deletions examples/typescript/__tests__/sum.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.

import {expect, it} from '@jest/globals';

it('adds 1 + 2 to equal 3 in Typescript', () => {
const sum = require('../sum.ts').default;
expect(sum(1, 2)).toBe(3);
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.0.0",
"@types/jest": "^27.4.0",
"@jest/globals": "workspace:^",
"babel-jest": "workspace:^",
"jest": "workspace:^"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@babel/register": "^7.0.0",
"@crowdin/cli": "^3.5.2",
"@jest/globals": "workspace:^",
"@jest/test-globals": "workspace:^",
"@jest/test-utils": "workspace:^",
"@lerna-lite/cli": "^1.11.3",
"@microsoft/api-extractor": "^7.29.0",
Expand All @@ -20,7 +21,6 @@
"@types/babel__generator": "^7.0.0",
"@types/babel__template": "^7.0.2",
"@types/dedent": "^0.7.0",
"@types/jest": "^27.4.0",
"@types/node": "~14.14.45",
"@types/which": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.14.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/babel-jest/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
mrazauskas marked this conversation as resolved.
Show resolved Hide resolved
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/babel-plugin-jest-hoist/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/diff-sequences/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
2 changes: 2 additions & 0 deletions packages/expect-utils/src/__tests__/isError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @jest-environment jsdom
*/

/// <reference lib="dom" />

/* eslint-env browser */

import {isError} from '../utils';
Expand Down
9 changes: 9 additions & 0 deletions packages/expect-utils/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
3 changes: 3 additions & 0 deletions packages/expect/src/__tests__/toEqual-dom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*
* @jest-environment jsdom
*/

/// <reference lib="dom" />

/* eslint-env browser*/

describe('toEqual', () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/expect/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-circus/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
4 changes: 1 addition & 3 deletions packages/jest-circus/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "build",
"rootDir": "src",
// we don't want `@types/jest` to be referenced
"types": []
"rootDir": "src"
},
"include": ["./src/**/*"],
"exclude": ["./**/__mocks__/**/*", "./**/__tests__/**/*"],
Expand Down
9 changes: 9 additions & 0 deletions packages/jest-cli/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-cli/src/init/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-config/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-console/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-core/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-core/src/lib/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-core/src/plugins/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-diff/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-docblock/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-each/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-environment-jsdom/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-environment-node/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
2 changes: 0 additions & 2 deletions packages/jest-environment/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
// we don't want `@types/jest` to be referenced
"types": ["node"],
"rootDir": "src",
"outDir": "build"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/// <reference lib="dom" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really? how? it's running in node env, so shouldn't need or use any DOM APIs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, for rAF it makes sense 👍


import * as util from 'util';
import {runInNewContext} from 'vm';
import {ModuleMocker} from 'jest-mock';
Expand Down
9 changes: 9 additions & 0 deletions packages/jest-fake-timers/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-get-type/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-globals/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
2 changes: 0 additions & 2 deletions packages/jest-globals/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
// we don't want `@types/jest` to be referenced
"types": [],
"rootDir": "src",
"outDir": "build"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/jest-haste-map/src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
9 changes: 9 additions & 0 deletions packages/jest-haste-map/src/crawlers/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"composite": false,
"rootDir": "../",
"types": ["@jest/test-globals"]
},
"include": ["../**/*"]
}
Loading