Skip to content

Commit

Permalink
Do not start a shell to run child process
Browse files Browse the repository at this point in the history
  • Loading branch information
abdala committed Nov 25, 2024
1 parent 8ef914b commit d9ad097
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
5 changes: 2 additions & 3 deletions dtc-playwright-plugin/src/playwright-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

export default (constructorArgs?: string[]) =>
async (testCaseExecutions: TestCaseExecution[], _plugins: string[], runnerArgs: string[], config?: string) => {
const args = [...runnerArgs, ...constructorArgs ?? []]
const childProcess = spawnSync(`npx playwright test ${args?.join(' ')} ${__dirname}`, {
const args = ['playwright', 'test', ...runnerArgs, ...constructorArgs ?? [], __dirname]
const childProcess = spawnSync('npx', args, {
stdio: 'inherit',
shell: true,
env: {
...process.env,
...(testCaseExecutions.length === 1 && {DTC_PLAYWRIGHT_PATH: testCaseExecutions[0].filePath}),
Expand Down
12 changes: 3 additions & 9 deletions dtc/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ import {fileURLToPath} from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))

test('It executes test using cli', async () => {
const childProcess = spawnSync(`npx tsx ${__dirname}/../src/cli.ts ./test/fixtures/unit.js`, {
const childProcess = spawnSync('npx', ['tsx', `${__dirname}/../src/cli.ts`, './test/fixtures/unit.js'], {
stdio: 'inherit',
shell: true,
})

nodeAssert.equal(childProcess.status, 0)
})

test('It fails test using cli', async () => {
const childProcess = spawnSync(`npx tsx ${__dirname}/../src/cli.ts ./test/fixtures/unit-fail.js`, {
shell: true,
})
const childProcess = spawnSync('npx', ['tsx', `${__dirname}/../src/cli.ts`, './test/fixtures/unit-fail.js'])

nodeAssert.equal(childProcess.status, 1)
})

test('It executes all files', async () => {
const childProcess = spawnSync(`npx tsx ${__dirname}/../src/cli.ts`, {
stdio: 'inherit',
shell: true,
})
const childProcess = spawnSync('npx', ['tsx', `${__dirname}/../src/cli.ts`], {stdio: 'inherit'})

nodeAssert.equal(childProcess.status, 0)
})

0 comments on commit d9ad097

Please sign in to comment.