From 6788b9cf8c3c3ffdcccecafd9f4ce47917e9c04a Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Wed, 9 Jun 2021 11:18:32 -0700 Subject: [PATCH] fix(@playwright/test): plumbing (#6992) `npx playwright test` should find and forward to the @playwright/test package. --- src/cli/cli.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 36f81bfbee..e61a69882e 100755 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -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.');