mirror of
https://gh.wpcy.net/https://github.com/elementor/elementor.git
synced 2026-04-20 12:23:54 +08:00
## PR Checklist <!-- Please check if your PR fulfills the following requirements: **Filling out the template is required.** Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. --> - [ ] The commit message follows our guidelines: https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x" with no spaces eg: [x]. --> - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, local variables) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes - [ ] Documentation content changes - [ ] Other... Please describe: ## Summary This PR can be summarized in the following changelog entry: * ## Description An explanation of what is done in this PR * ## Test instructions This PR can be tested by following these steps: * ## Quality assurance - [ ] I have tested this code to the best of my abilities - [ ] I have added unittests to verify the code works as intended - [ ] Docs have been added / updated (for bug fixes / features) Fixes # --------- Co-authored-by: ElementorBot <48412871+elementorbot@users.noreply.github.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
const { spawn, exec } = require( 'child_process' );
|
|
const packageJson = require( './package.json' );
|
|
|
|
function isDockerExist() {
|
|
return new Promise( ( resolve ) => {
|
|
exec( 'docker -v', ( error ) => {
|
|
resolve( ! error );
|
|
} );
|
|
} );
|
|
}
|
|
|
|
async function run( tag ) {
|
|
const playwrightVersion = packageJson.devDependencies[ '@playwright/test' ];
|
|
const workingDir = process.cwd();
|
|
|
|
const command = 'docker run';
|
|
const options = [
|
|
'--rm',
|
|
'--network host',
|
|
`--volume ${ workingDir }:/work`,
|
|
'--workdir /work/',
|
|
'--interactive',
|
|
process.env.CI ? '' : '--tty',
|
|
];
|
|
const image = `mcr.microsoft.com/playwright:v${ playwrightVersion.replace( '^', '' ) }-jammy`;
|
|
const commandToRun = `/bin/bash -c "npm run test:playwright -- --grep="${ tag }""`;
|
|
|
|
spawn( `${ command } ${ options.join( ' ' ) } ${ image } ${ commandToRun }`, {
|
|
stdio: 'inherit',
|
|
stderr: 'inherit',
|
|
shell: true,
|
|
} );
|
|
}
|
|
|
|
( async () => {
|
|
if ( ! await isDockerExist() ) {
|
|
// eslint-disable-next-line no-console
|
|
console.error( 'Docker is not installed, please install it first.' );
|
|
|
|
process.exit( 1 );
|
|
}
|
|
|
|
await run( process.argv.slice( 2 ) );
|
|
} )();
|