-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from stellarwp/playwright-support
Playwright support
- Loading branch information
Showing
6 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Handles Playwright commands. | ||
* | ||
* @var bool $is_help Whether we're handling an `help` request on this command or not. | ||
* @var Closure $args The argument map closure, as produced by the `args` function. | ||
* @var string $cli_name The current name of the `slic` CLI application. | ||
*/ | ||
|
||
namespace StellarWP\Slic; | ||
|
||
if ( $is_help ) { | ||
$help = <<< HELP | ||
SUMMARY: | ||
This command requires a use target set using the <light_cyan>use</light_cyan> command. | ||
USAGE: | ||
<yellow>{$cli_name} playwright [...<commands>]</yellow> | ||
EXAMPLES: | ||
<light_cyan>{$cli_name} playwright install</light_cyan> | ||
Install Playwright dependencies in the current <light_cyan>use</light_cyan> target. | ||
<light_cyan>{$cli_name} playwright test</light_cyan> | ||
Run all Playwright tests following the Playwright configuration in the current <light_cyan>use</light_cyan> target. | ||
<light_cyan>{$cli_name} playwright test tests/e2e/my-test.spec.ts</light_cyan> | ||
Run a specific Playwright test file from the root directory of the <light_cyan>use</light_cyan> target. | ||
HELP; | ||
|
||
echo colorize( $help ); | ||
|
||
return; | ||
} | ||
|
||
$using = slic_target_or_fail(); | ||
echo light_cyan( "Using {$using}" . PHP_EOL ); | ||
|
||
ensure_service_running( 'slic' ); | ||
|
||
setup_id(); | ||
$playwright_args = $args( '...' ); | ||
$status = slic_realtime()( | ||
array_merge( | ||
[ | ||
'exec', | ||
'--user', | ||
sprintf( '"%s:%s"', getenv( 'SLIC_UID' ), getenv( 'SLIC_GID' ) ), | ||
'--workdir', | ||
escapeshellarg( get_project_container_path() ), | ||
'slic', | ||
'node_modules/.bin/playwright', | ||
], | ||
$playwright_args | ||
) | ||
); | ||
|
||
// If there is a status other than 0, we have an error. Bail. | ||
if ( $status ) { | ||
exit( $status ); | ||
} | ||
|
||
exit( $status ); |