Skip to content

Commit

Permalink
refactor: revert to old playwright engine code-2.0.3-67408d1
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Jan 23, 2024
1 parent ccfe592 commit b2a6b37
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions packages/artillery-engine-playwright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class PlaywrightEngine {
typeof script.config.engines.playwright.showAllPageMetrics !==
'undefined';

this.useSeparateBrowserPerVU =
typeof script.config.engines.playwright.useSeparateBrowserPerVU === 'boolean' ?
script.config.engines.playwright.useSeparateBrowserPerVU : false;

return this;
}

Expand Down Expand Up @@ -68,18 +64,8 @@ class PlaywrightEngine {

const contextOptions = self.contextOptions || {};

let browser;
if (self.useSeparateBrowserPerVU) {
browser = await chromium.launch(launchOptions);
debug('new browser created');
} else {
if (!global.artillery.__browser) {
global.artillery.__browser = await chromium.launch(launchOptions);
debug('shared browser created');
}
browser = global.artillery.__browser;
}

const browser = await chromium.launch(launchOptions);
debug('browser created');
const context = await browser.newContext(contextOptions);

context.setDefaultNavigationTimeout(self.defaultNavigationTimeout);
Expand Down Expand Up @@ -110,13 +96,7 @@ class PlaywrightEngine {

debug('page created');

page.on('response', (response) => {
const status = response.status();
events.emit('counter', 'browser.page.codes.' + status, 1);
});

page.on('domcontentloaded', async (page) => {

if (!self.extendedMetrics) {
return;
}
Expand Down Expand Up @@ -246,10 +226,7 @@ class PlaywrightEngine {
}
} finally {
await context.close();

if (self.useSeparateBrowserPerVU) {
await browser.close();
}
await browser.close();
}
};
}
Expand Down

0 comments on commit b2a6b37

Please sign in to comment.