annotate context type, defaultTimeout 30s -> 10s

This commit is contained in:
Ralf Vogler 2021-12-28 18:26:27 +01:00
parent 567365e46c
commit 83a4b064bd
2 changed files with 5 additions and 2 deletions

View file

@ -1,3 +1,4 @@
//@ts-check
const { existsSync } = require('fs'); const { existsSync } = require('fs');
if (!existsSync('auth.json')) { if (!existsSync('auth.json')) {
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.'); console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.');
@ -50,10 +51,12 @@ const newStealthContext = async (browser, contextOptions = {}) => {
channel: 'chrome', channel: 'chrome',
headless: false, headless: false,
}); });
/** @type {import('playwright').BrowserContext} */
const context = await newStealthContext(browser, { const context = await newStealthContext(browser, {
storageState: 'auth.json', storageState: 'auth.json',
viewport: { width: 1280, height: 1280 }, viewport: { width: 1280, height: 1280 },
}); });
context.setDefaultTimeout(10000);
const page = await context.newPage(); const page = await context.newPage();
await page.goto('https://www.epicgames.com/store/en-US/free-games'); await page.goto('https://www.epicgames.com/store/en-US/free-games');
// await expect(page.locator('a[role="button"]:has-text("Sign In")')).toHaveCount(0); // await expect(page.locator('a[role="button"]:has-text("Sign In")')).toHaveCount(0);

View file

@ -2,9 +2,9 @@
"scripts": { "scripts": {
"login": "npx playwright open --save-storage=auth.json https://www.epicgames.com/login", "login": "npx playwright open --save-storage=auth.json https://www.epicgames.com/login",
"codegen": "npx playwright codegen --load-storage=auth.json https://www.epicgames.com/store/en-US/free-games", "codegen": "npx playwright codegen --load-storage=auth.json https://www.epicgames.com/store/en-US/free-games",
"start": "npx playwright test --timeout 10000", "test": "npx playwright test --timeout 10000",
"debug": "npx playwright test --debug", "debug": "npx playwright test --debug",
"stealth": "node main.stealth" "start": "node main.stealth"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.17.1", "@playwright/test": "^1.17.1",