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

Always import jest from @jest/globals #13880

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.cjs
Expand Up @@ -68,6 +68,9 @@ module.exports = {
"jest/no-test-callback": "off",
"jest/valid-describe": "off",
"import/extensions": ["error", { json: "always", cjs: "always" }],
// The "jest" global is not available when using native ESM. For consistency,
// always disallow it.
"no-restricted-globals": ["error", "jest"],
},
},
{
Expand All @@ -86,7 +89,9 @@ module.exports = {
"packages/babel-register/**/*.js",
],
rules: {
"no-restricted-globals": ["error", ...cjsGlobals],
// The "jest" global is not available when using native ESM. For consistency,
// always disallow it.
"no-restricted-globals": ["error", ...cjsGlobals, "jest"],
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -59,8 +59,8 @@
"gulp-filter": "^7.0.0",
"gulp-plumber": "^1.2.1",
"husky": "^3.0.0",
"jest": "^27.2.0",
"jest-worker": "^27.2.0",
"jest": "^27.3.1",
"jest-worker": "^27.3.1",
"lint-staged": "^9.2.0",
"lodash": "^4.17.21",
"mergeiterator": "^1.2.5",
Expand Down
1 change: 1 addition & 0 deletions packages/babel-cli/package.json
Expand Up @@ -42,6 +42,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-fixtures": "workspace:*",
"@jest/globals": "^27.3.1",
"rimraf": "^3.0.0"
},
"bin": {
Expand Down
1 change: 1 addition & 0 deletions packages/babel-cli/test/index.js
Expand Up @@ -6,6 +6,7 @@ import path from "path";
import fs from "fs";
import { fileURLToPath } from "url";
import { createRequire } from "module";
import { jest } from "@jest/globals";

import { chmod } from "../lib/babel/util";

Expand Down
1 change: 1 addition & 0 deletions packages/babel-core/package.json
Expand Up @@ -67,6 +67,7 @@
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "workspace:*",
"@babel/plugin-transform-modules-commonjs": "workspace:*",
"@jest/globals": "^27.3.1",
"@types/convert-source-map": "^1.5.1",
"@types/debug": "^4.1.0",
"@types/resolve": "^1.3.2",
Expand Down
1 change: 1 addition & 0 deletions packages/babel-core/test/assumptions.js
Expand Up @@ -2,6 +2,7 @@ import path from "path";
import { fileURLToPath } from "url";
import { loadOptions as loadOptionsOrig, transformSync } from "../lib";
import pluginCommonJS from "@babel/plugin-transform-modules-commonjs";
import { jest } from "@jest/globals";

const cwd = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Expand Up @@ -24,7 +24,8 @@
"source-map": "^0.5.0"
},
"devDependencies": {
"@types/jest": "^25.2.2"
"@jest/globals": "^27.3.1",
"@types/jest": "^27.0.2"
},
"engines": {
"node": ">=6.9.0"
Expand Down
Expand Up @@ -14,6 +14,7 @@ import path from "path";
import vm from "vm";
import QuickLRU from "quick-lru";
import { fileURLToPath } from "url";
import { jest } from "@jest/globals";

import { createRequire } from "module";
const require = createRequire(import.meta.url);
Expand Down
1 change: 1 addition & 0 deletions packages/babel-register/package.json
Expand Up @@ -29,6 +29,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/plugin-transform-modules-commonjs": "workspace:*",
"@jest/globals": "^27.3.1",
"browserify": "^16.5.2"
},
"homepage": "https://babel.dev/docs/en/next/babel-register",
Expand Down
1 change: 1 addition & 0 deletions packages/babel-register/test/cache.js
@@ -1,6 +1,7 @@
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { jest } from "@jest/globals";

const testCacheFilename = path.join(
path.dirname(fileURLToPath(import.meta.url)),
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-register/test/index.js
Expand Up @@ -4,6 +4,10 @@ const fs = require("fs");
const path = require("path");
const child = require("child_process");

// We cannot use "const" here, because Jest wraps this module in a function with a "jest" parameter.
// eslint-disable-next-line no-var
var { jest } = require("@jest/globals");

let currentHook;
let currentOptions;
let sourceMapSupport = false;
Expand Down