Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Sep 6, 2024
1 parent 51126f7 commit 7f02bbb
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/debug-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,49 @@ test('should end test run when stopping the debugging', async ({ activate }, tes
testRun.token.source.cancel();
});

test('should end test run when stopping the debugging during config parsing', async ({ activate }) => {
const { vscode, testController } = await activate({
'package.json': JSON.stringify({ type: 'module' }),
'playwright.config.js': `
// Simulate breakpoint via stalling.
async function stall() {
console.log('READY TO BREAK');
await new Promise(() => {});
}
process.env.STALL_CONFIG === '1' && await stall();
export default { testDir: 'tests' }
`,
'tests/test.spec.ts': `
import { test } from '@playwright/test';
test('should fail', async () => {});
`,
}, { env: { STALL_CONFIG: '0' } });

await testController.expandTestItems(/test.spec/);
const testItems = testController.findTestItems(/fail/);

const configuration = vscode.workspace.getConfiguration('playwright');
configuration.update('env', { STALL_CONFIG: '1' });

const profile = testController.debugProfile();
const testRunPromise = new Promise<TestRun>(f => testController.onDidCreateTestRun(f));
profile.run(testItems);
const testRun = await testRunPromise;
await expect.poll(() => vscode.debug.output).toContain('READY TO BREAK');

const endPromise = new Promise(f => testRun.onDidEnd(f));
vscode.debug.stopDebugging();
await endPromise;

expect(testRun.renderLog({ messages: true })).toBe(`
tests > test.spec.ts > should fail [2:0]
enqueued
`);

testRun.token.source.cancel();
});

test('should pass all args as string[] when debugging', async ({ activate }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30829' });
const { vscode, testController } = await activate({
Expand Down

0 comments on commit 7f02bbb

Please sign in to comment.