Skip to content

Commit da2cecb

Browse files
authored
chore: don't close page in generated test (#12022)
1 parent 2815180 commit da2cecb

File tree

1 file changed

+3
-2
lines changed
  • packages/playwright-core/src/server/supplements/recorder

1 file changed

+3
-2
lines changed

packages/playwright-core/src/server/supplements/recorder/javascript.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ export class JavaScriptLanguageGenerator implements LanguageGenerator {
3636

3737
generateAction(actionInContext: ActionInContext): string {
3838
const action = actionInContext.action;
39+
if (this._isTest && (action.name === 'openPage' || action.name === 'closePage'))
40+
return '';
41+
3942
const pageAlias = actionInContext.frame.pageAlias;
4043
const formatter = new JavaScriptFormatter(2);
4144
formatter.newLine();
4245
formatter.add('// ' + actionTitle(action));
4346

4447
if (action.name === 'openPage') {
45-
if (this._isTest)
46-
return '';
4748
formatter.add(`const ${pageAlias} = await context.newPage();`);
4849
if (action.url && action.url !== 'about:blank' && action.url !== 'chrome://newtab/')
4950
formatter.add(`await ${pageAlias}.goto(${quote(action.url)});`);

0 commit comments

Comments
 (0)