mirror of
https://github.com/hanzoai/jest.git
synced 2026-09-24 16:59:57 +00:00
chore: move @jest/test-utils reference (#13468)
This commit is contained in:
+2
-1
@@ -3,5 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"rootDir": "./"
|
||||
},
|
||||
"include": ["./**/*"]
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../packages/test-utils"}]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["./**/__tests__/**/*"],
|
||||
// TODO: include `babel-preset-jest` if it's ever in TS even though we don't care about its types
|
||||
"references": [{"path": "../jest-transform"}, {"path": "../test-utils"}]
|
||||
"references": [{"path": "../jest-transform"}]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
{"path": "../jest-get-type"},
|
||||
{"path": "../jest-matcher-utils"},
|
||||
{"path": "../jest-message-util"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"references": [
|
||||
{"path": "../jest-message-util"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../"
|
||||
},
|
||||
"include": ["../**/*"]
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../../"}]
|
||||
"references": [{"path": "../../../"}, {"path": "../../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../jest-validate"},
|
||||
{"path": "../jest-watcher"},
|
||||
{"path": "../pretty-format"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"references": [
|
||||
{"path": "../diff-sequences"},
|
||||
{"path": "../jest-get-type"},
|
||||
{"path": "../pretty-format"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
{"path": "../jest-fake-timers"},
|
||||
{"path": "../jest-mock"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
{"path": "../jest-fake-timers"},
|
||||
{"path": "../jest-mock"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
{"path": "../jest-message-util"},
|
||||
{"path": "../jest-mock"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
"walker": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "workspace:^",
|
||||
"@types/fb-watchman": "^2.0.0",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"slash": "^3.0.0"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
{"path": "../jest-regex-util"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../jest-worker"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-worker"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"references": [
|
||||
{"path": "../jest-diff"},
|
||||
{"path": "../jest-get-type"},
|
||||
{"path": "../pretty-format"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
{"path": "../jest-transform"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../jest-worker"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-worker"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
{"path": "../jest-resolve"},
|
||||
{"path": "../jest-runtime"},
|
||||
{"path": "../jest-snapshot"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-types"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"source-map-support": "0.5.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "workspace:^",
|
||||
"@tsd/typescript": "^4.9.0",
|
||||
"@types/exit": "^0.1.30",
|
||||
"@types/graceful-fs": "^4.1.3",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
{"path": "../jest-test-result"},
|
||||
{"path": "../jest-transform"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
{"path": "../jest-transform"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../pretty-format"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -6,9 +6,5 @@
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["./**/__tests__/**/*"],
|
||||
"references": [
|
||||
{"path": "../jest-haste-map"},
|
||||
{"path": "../jest-test-result"},
|
||||
{"path": "../test-utils"}
|
||||
]
|
||||
"references": [{"path": "../jest-haste-map"}, {"path": "../jest-test-result"}]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.json",
|
||||
"include": ["./**/*"],
|
||||
"references": [{"path": "../../"}]
|
||||
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
{"path": "../jest-haste-map"},
|
||||
{"path": "../jest-regex-util"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../jest-util"},
|
||||
{"path": "../test-utils"}
|
||||
{"path": "../jest-util"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/globals": "workspace:^",
|
||||
"@jest/types": "workspace:^",
|
||||
"@types/node": "*",
|
||||
"ansi-regex": "^5.0.1",
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import semver = require('semver');
|
||||
import type {Global} from '@jest/types';
|
||||
/* eslint-disable jest/no-focused-tests */
|
||||
|
||||
declare const describe: Global.TestFrameworkGlobals['describe'];
|
||||
declare const test: Global.TestFrameworkGlobals['test'];
|
||||
import semver = require('semver');
|
||||
import {describe, test} from '@jest/globals';
|
||||
|
||||
export function isJestJasmineRun(): boolean {
|
||||
return process.env.JEST_JASMINE === '1';
|
||||
|
||||
@@ -5,5 +5,9 @@
|
||||
"outDir": "build"
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"references": [{"path": "../jest-types"}, {"path": "../pretty-format"}]
|
||||
"references": [
|
||||
{"path": "../jest-globals"},
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ packagesWithTs.forEach(({packageDir, pkg}) => {
|
||||
}
|
||||
}
|
||||
|
||||
// only test files depend on '@jest/test-utils', i.e. it is always a dev dependency
|
||||
// see additional checks below
|
||||
if (dep === '@jest/test-utils') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.map(dep =>
|
||||
@@ -84,6 +90,60 @@ packagesWithTs.forEach(({packageDir, pkg}) => {
|
||||
)}\nExpected:\n\n${jestDependenciesOfPackage.join('\n')}`,
|
||||
);
|
||||
}
|
||||
|
||||
let hasJestTestUtils = Object.keys(pkg.dependencies || {}).includes(
|
||||
'@jest/test-utils',
|
||||
);
|
||||
|
||||
if (hasJestTestUtils) {
|
||||
throw new Error(
|
||||
chalk.red(
|
||||
`Package '${pkg.name}' declares '@jest/test-utils' as dependency, but it must be declared as dev dependency`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
hasJestTestUtils = Object.keys(pkg.devDependencies || {}).includes(
|
||||
'@jest/test-utils',
|
||||
);
|
||||
|
||||
const tsConfigPaths = glob.sync('**/__tests__/tsconfig.json', {
|
||||
absolute: true,
|
||||
cwd: packageDir,
|
||||
});
|
||||
|
||||
const testUtilsReferences = tsConfigPaths.filter(tsConfigPath => {
|
||||
const tsConfig = JSON.parse(
|
||||
stripJsonComments(fs.readFileSync(tsConfigPath, 'utf8')),
|
||||
);
|
||||
const references = tsConfig.references.map(({path}) => path);
|
||||
|
||||
return references.some(reference => /test-utils$/.test(reference));
|
||||
});
|
||||
|
||||
if (hasJestTestUtils && testUtilsReferences.length === 0) {
|
||||
throw new Error(
|
||||
chalk.red(
|
||||
`Package '${
|
||||
pkg.name
|
||||
}' declares '@jest/test-utils' as dev dependency, but it is not referenced in:\n\n${tsConfigPaths.join(
|
||||
'\n',
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (!hasJestTestUtils && testUtilsReferences.length > 0) {
|
||||
throw new Error(
|
||||
chalk.red(
|
||||
`Package '${
|
||||
pkg.name
|
||||
}' does not declare '@jest/test-utils' as dev dependency, but it is referenced in:\n\n${testUtilsReferences.join(
|
||||
'\n',
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const args = [
|
||||
|
||||
@@ -2970,6 +2970,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@jest/test-utils@workspace:packages/test-utils"
|
||||
dependencies:
|
||||
"@jest/globals": "workspace:^"
|
||||
"@jest/types": "workspace:^"
|
||||
"@types/node": "*"
|
||||
"@types/semver": ^7.1.0
|
||||
@@ -12768,7 +12769,6 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "jest-haste-map@workspace:packages/jest-haste-map"
|
||||
dependencies:
|
||||
"@jest/test-utils": "workspace:^"
|
||||
"@jest/types": "workspace:^"
|
||||
"@types/fb-watchman": ^2.0.0
|
||||
"@types/graceful-fs": ^4.1.3
|
||||
@@ -12996,6 +12996,7 @@ __metadata:
|
||||
"@jest/console": "workspace:^"
|
||||
"@jest/environment": "workspace:^"
|
||||
"@jest/test-result": "workspace:^"
|
||||
"@jest/test-utils": "workspace:^"
|
||||
"@jest/transform": "workspace:^"
|
||||
"@jest/types": "workspace:^"
|
||||
"@tsd/typescript": ^4.9.0
|
||||
|
||||
Reference in New Issue
Block a user