fix(@playwright/test): plumbing (#6992)

`npx playwright test` should find and forward to the @playwright/test package.
This commit is contained in:
Joel Einbinder 2021-06-09 11:18:32 -07:00 committed by GitHub
parent 048a380462
commit 6788b9cf8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,8 +250,20 @@ program
});
if (!process.env.PW_CLI_TARGET_LANG) {
if (packageJSON.name === '@playwright/test' || process.env.PWTEST_CLI_ALLOW_TEST_COMMAND) {
require('../test/cli').addTestCommand(program);
let playwrightTestPackagePath = null;
try {
const isLocal = packageJSON.name === '@playwright/test' || process.env.PWTEST_CLI_ALLOW_TEST_COMMAND;
if (isLocal) {
playwrightTestPackagePath = '../test/cli';
} else {
playwrightTestPackagePath = require.resolve('@playwright/test/lib/test/cli', {
paths: [__dirname, process.cwd()]
});
}
} catch {}
if (playwrightTestPackagePath) {
require(playwrightTestPackagePath).addTestCommand(program);
} else {
const command = program.command('test');
command.description('Run tests with Playwright Test. Available in @playwright/test package.');