Skip to content

Commit

Permalink
cherry-pick(release-1.12): fix @playwright/test plumbing (#6994)
Browse files Browse the repository at this point in the history
Cherry-pick #6992 SHA 6788b9c

Co-authored-by: Joel Einbinder <joel.einbinder@gmail.com>
  • Loading branch information
aslushnikov and JoelEinbinder authored Jun 9, 2021
1 parent 0d845e0 commit af4d008
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit af4d008

Please sign in to comment.