mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
test: pick Chrome debugging port by Jest worker ID
This commit is contained in:
parent
547edeb6dd
commit
277f05513e
1 changed files with 7 additions and 1 deletions
|
@ -57,6 +57,12 @@ class SeleniumHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDriver () {
|
getDriver () {
|
||||||
|
// JEST_WORKER_ID will always be '1' with --runInBand
|
||||||
|
// in that case, we want to use the default port so tools like VSCode can attach to the debugger
|
||||||
|
const defaultPort = 9222;
|
||||||
|
const workerIndex = parseInt(process.env.JEST_WORKER_ID || '1', 10) - 1; // one-based ID => zero-based index
|
||||||
|
const portNumber = defaultPort + workerIndex;
|
||||||
|
|
||||||
const chromeOptions = new chrome.Options();
|
const chromeOptions = new chrome.Options();
|
||||||
if (headless) {
|
if (headless) {
|
||||||
chromeOptions.addArguments('--headless');
|
chromeOptions.addArguments('--headless');
|
||||||
|
@ -64,7 +70,7 @@ class SeleniumHelper {
|
||||||
chromeOptions.addArguments('window-size=1024,1680');
|
chromeOptions.addArguments('window-size=1024,1680');
|
||||||
chromeOptions.addArguments('--no-sandbox');
|
chromeOptions.addArguments('--no-sandbox');
|
||||||
chromeOptions.addArguments('--disable-dev-shm-using');
|
chromeOptions.addArguments('--disable-dev-shm-using');
|
||||||
chromeOptions.addArguments('--remote-debugging-port=9222');
|
chromeOptions.addArguments(`--remote-debugging-port=${portNumber}`);
|
||||||
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
|
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
|
||||||
let driver = new webdriver.Builder()
|
let driver = new webdriver.Builder()
|
||||||
.forBrowser('chrome')
|
.forBrowser('chrome')
|
||||||
|
|
Loading…
Reference in a new issue