chore: validate pw-core version when pwtest CLI gets executed (#16475)
This commit is contained in:
parent
2142fde460
commit
35a9daa425
|
|
@ -309,13 +309,33 @@ Examples:
|
||||||
|
|
||||||
if (!process.env.PW_LANG_NAME) {
|
if (!process.env.PW_LANG_NAME) {
|
||||||
let playwrightTestPackagePath = null;
|
let playwrightTestPackagePath = null;
|
||||||
|
const resolvePwTestPaths = [__dirname, process.cwd()];
|
||||||
try {
|
try {
|
||||||
playwrightTestPackagePath = require.resolve('@playwright/test/lib/cli', {
|
playwrightTestPackagePath = require.resolve('@playwright/test/lib/cli', {
|
||||||
paths: [__dirname, process.cwd()]
|
paths: resolvePwTestPaths,
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (playwrightTestPackagePath) {
|
if (playwrightTestPackagePath) {
|
||||||
|
const pwTestVersion = require(require.resolve('@playwright/test/package.json', {
|
||||||
|
paths: resolvePwTestPaths,
|
||||||
|
})).version;
|
||||||
|
const pwCoreVersion = require(path.join(__dirname, '../../package.json')).version;
|
||||||
|
if (pwTestVersion !== pwCoreVersion) {
|
||||||
|
let hasPlaywrightPackage = false;
|
||||||
|
try {
|
||||||
|
require('playwright');
|
||||||
|
hasPlaywrightPackage = true;
|
||||||
|
} catch {}
|
||||||
|
console.error(wrapInASCIIBox([
|
||||||
|
`Playwright Test compatibility check failed:`,
|
||||||
|
`@playwright/test version '${pwTestVersion}' does not match ${hasPlaywrightPackage ? 'playwright' : 'playwright-core'} version '${pwCoreVersion}'!`,
|
||||||
|
`To fix this either align the versions or only keep @playwright/test since it depends on playwright-core.`,
|
||||||
|
`If you still receive this error, execute 'npm ci' or delete 'node_modules' and do 'npm install' again.`,
|
||||||
|
].join('\n'), 1));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require(playwrightTestPackagePath).addTestCommands(program);
|
require(playwrightTestPackagePath).addTestCommands(program);
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue