Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: migrate page tests to new folio (#6054)

Dmitry Gozman06299227742d
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 8866870a07..b310b6a614 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -277,11 +277,7 @@ jobs:
- name: Start Android Emulator
run: utils/avd_start.sh
- name: Run tests
- run: npm run build-folio && node tests/folio/cli.js --config=tests/config/android.config.ts
- env:
- FOLIO_JSON_OUTPUT_NAME: "test-results/report-new.json"
- - name: Run page tests
- run: npx folio test/page -p browserName=chromium --workers=1 --forbid-only --timeout=120000 --global-timeout=5400000 --retries=3 --reporter=dot,json
+ run: npm run build-folio && node tests/folio/cli.js --config=tests/config/android.config.ts --reporter=dot,json
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always() && github.repository == 'microsoft/playwright' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-'))
- uses: actions/upload-artifact@v1
diff --git a/test/browsercontext-set-extra-http-headers.spec.ts b/test/browsercontext-set-extra-http-headers.spec.ts
index 2ee4a1fe79..5fe0a97c1c 100644
--- a/test/browsercontext-set-extra-http-headers.spec.ts
+++ b/test/browsercontext-set-extra-http-headers.spec.ts
@@ -33,3 +33,8 @@ it('should override extra headers from browser context', async ({browser, server
expect(request.headers['foo']).toBe('Bar');
expect(request.headers['bar']).toBe('foO');
});
+
+it('should throw for non-string header values', async ({browser}) => {
+ const error3 = await browser.newContext({ extraHTTPHeaders: { 'foo': null } }).catch(e => e);
+ expect(error3.message).toContain('Expected value of header "foo" to be String, but "object" is found.');
+});
diff --git a/test/page/README.md b/test/page/README.md
deleted file mode 100644
index 38e7463716..0000000000
--- a/test/page/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Put tests that are scoped to a page and can run on Chrome for Android, WebView, Electron, etc.
\ No newline at end of file
diff --git a/tests/config/androidEnv.ts b/tests/config/androidEnv.ts
index be24da10ac..250e0f782d 100644
--- a/tests/config/androidEnv.ts
+++ b/tests/config/androidEnv.ts
@@ -41,6 +41,8 @@ export class AndroidEnv implements Env<AndroidTestArgs> {
isChromium: true,
isFirefox: false,
isWebKit: false,
+ browserName: 'chromium' as const,
+ browserChannel: undefined,
isWindows: os.platform() === 'win32',
isMac: os.platform() === 'darwin',
isLinux: os.platform() === 'linux',
diff --git a/tests/config/pageTest.ts b/tests/config/pageTest.ts
index e146352dcd..17698c98e2 100644
--- a/tests/config/pageTest.ts
+++ b/tests/config/pageTest.ts
@@ -26,6 +26,8 @@ export type CommonTestArgs = {
playwright: typeof import('../../index');
toImpl: (rpcObject: any) => any;
+ browserName: 'chromium' | 'firefox' | 'webkit';
+ browserChannel: string | undefined;
isChromium: boolean;
isFirefox: boolean;
diff --git a/tests/config/playwrightTest.ts b/tests/config/playwrightTest.ts
index d3942e255a..c14650a18f 100644
--- a/tests/config/playwrightTest.ts
+++ b/tests/config/playwrightTest.ts
@@ -22,9 +22,7 @@ import { RemoteServer, RemoteServerOptions } from './remoteServer';
export { expect } from 'folio';
export type PlaywrightTestArgs = CommonTestArgs & {
- browserName: 'chromium' | 'firefox' | 'webkit';
browserType: BrowserType<Browser>;
- browserChannel: string | undefined;
browserOptions: LaunchOptions;
headful: boolean;
createUserDataDir: () => Promise<string>;
diff --git a/test/page/elementhandle-click.spec.ts b/tests/elementhandle-click.spec.ts
similarity index 98%
rename from test/page/elementhandle-click.spec.ts
rename to tests/elementhandle-click.spec.ts
index 0434b2acd3..5d495ba810 100644
--- a/test/page/elementhandle-click.spec.ts
+++ b/tests/elementhandle-click.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/page/elementhandle-content-frame.spec.ts b/tests/elementhandle-content-frame.spec.ts
similarity index 95%
rename from test/page/elementhandle-content-frame.spec.ts
rename to tests/elementhandle-content-frame.spec.ts
index afeb3ee989..9ca6225a3d 100644
--- a/test/page/elementhandle-content-frame.spec.ts
+++ b/tests/elementhandle-content-frame.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame } from '../test/utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page/elementhandle-convenience.spec.ts b/tests/elementhandle-convenience.spec.ts
similarity index 99%
rename from test/page/elementhandle-convenience.spec.ts
rename to tests/elementhandle-convenience.spec.ts
index a5379cc9ed..b4754893b5 100644
--- a/test/page/elementhandle-convenience.spec.ts
+++ b/tests/elementhandle-convenience.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should have a nice preview', async ({ page, server }) => {
await page.goto(`${server.PREFIX}/dom.html`);
diff --git a/test/page/elementhandle-eval-on-selector.spec.ts b/tests/elementhandle-eval-on-selector.spec.ts
similarity index 98%
rename from test/page/elementhandle-eval-on-selector.spec.ts
rename to tests/elementhandle-eval-on-selector.spec.ts
index 94a7c6cdcf..3b1b164c6a 100644
--- a/test/page/elementhandle-eval-on-selector.spec.ts
+++ b/tests/elementhandle-eval-on-selector.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page, server}) => {
await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>');
diff --git a/test/page/elementhandle-misc.spec.ts b/tests/elementhandle-misc.spec.ts
similarity index 98%
rename from test/page/elementhandle-misc.spec.ts
rename to tests/elementhandle-misc.spec.ts
index 63b51efb5e..ca8320ddc0 100644
--- a/test/page/elementhandle-misc.spec.ts
+++ b/tests/elementhandle-misc.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should hover', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/scrollable.html');
diff --git a/test/page/elementhandle-owner-frame.spec.ts b/tests/elementhandle-owner-frame.spec.ts
similarity index 97%
rename from test/page/elementhandle-owner-frame.spec.ts
rename to tests/elementhandle-owner-frame.spec.ts
index 51557888ed..e5ce7f674b 100644
--- a/test/page/elementhandle-owner-frame.spec.ts
+++ b/tests/elementhandle-owner-frame.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame } from '../test/utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page/elementhandle-press.spec.ts b/tests/elementhandle-press.spec.ts
similarity index 97%
rename from test/page/elementhandle-press.spec.ts
rename to tests/elementhandle-press.spec.ts
index b5cffde123..ec88eeddd5 100644
--- a/test/page/elementhandle-press.spec.ts
+++ b/tests/elementhandle-press.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);
diff --git a/test/page/elementhandle-query-selector.spec.ts b/tests/elementhandle-query-selector.spec.ts
similarity index 98%
rename from test/page/elementhandle-query-selector.spec.ts
rename to tests/elementhandle-query-selector.spec.ts
index c606cc2754..202d386660 100644
--- a/test/page/elementhandle-query-selector.spec.ts
+++ b/tests/elementhandle-query-selector.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should query existing element', async ({page, server}) => {
await page.goto(server.PREFIX + '/playground.html');
diff --git a/test/page/elementhandle-scroll-into-view.spec.ts b/tests/elementhandle-scroll-into-view.spec.ts
similarity index 96%
rename from test/page/elementhandle-scroll-into-view.spec.ts
rename to tests/elementhandle-scroll-into-view.spec.ts
index 11c65581ad..5742b5c863 100644
--- a/test/page/elementhandle-scroll-into-view.spec.ts
+++ b/tests/elementhandle-scroll-into-view.spec.ts
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
+
+it('should work', async ({ page, server }) => {
+ it.fixme(process.env.PW_ANDROID_TESTS);
-it('should work', test => {
- test.fixme(process.env.PW_ANDROID_TESTS);
-}, async ({ page, server }) => {
await page.goto(server.PREFIX + '/offscreenbuttons.html');
for (let i = 0; i < 11; ++i) {
const button = await page.$('#btn' + i);
diff --git a/test/page/elementhandle-select-text.spec.ts b/tests/elementhandle-select-text.spec.ts
similarity index 98%
rename from test/page/elementhandle-select-text.spec.ts
rename to tests/elementhandle-select-text.spec.ts
index 018912fac2..4c88f504f3 100644
--- a/test/page/elementhandle-select-text.spec.ts
+++ b/tests/elementhandle-select-text.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should select textarea', async ({ page, server, isFirefox }) => {
await page.goto(server.PREFIX + '/input/textarea.html');
diff --git a/test/page/elementhandle-type.spec.ts b/tests/elementhandle-type.spec.ts
similarity index 97%
rename from test/page/elementhandle-type.spec.ts
rename to tests/elementhandle-type.spec.ts
index 44e9fa8f93..bce65b2362 100644
--- a/test/page/elementhandle-type.spec.ts
+++ b/tests/elementhandle-type.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);
diff --git a/test/page/elementhandle-wait-for-element-state.spec.ts b/tests/elementhandle-wait-for-element-state.spec.ts
similarity index 96%
rename from test/page/elementhandle-wait-for-element-state.spec.ts
rename to tests/elementhandle-wait-for-element-state.spec.ts
index 7d255406a4..a90b296900 100644
--- a/test/page/elementhandle-wait-for-element-state.spec.ts
+++ b/tests/elementhandle-wait-for-element-state.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
async function giveItAChanceToResolve(page) {
for (let i = 0; i < 5; i++)
@@ -114,9 +114,9 @@ it('should wait for disabled button', async ({page}) => {
await promise;
});
-it('should wait for stable position', (test, { browserName, platform }) => {
- test.fixme(browserName === 'firefox' && platform === 'linux');
-}, async ({page, server}) => {
+it('should wait for stable position', async ({page, server, isFirefox, platform}) => {
+ it.fixme(isFirefox && platform === 'linux');
+
await page.goto(server.PREFIX + '/input/button.html');
const button = await page.$('button');
await page.$eval('button', button => {
diff --git a/test/page/eval-on-selector-all.spec.ts b/tests/eval-on-selector-all.spec.ts
similarity index 98%
rename from test/page/eval-on-selector-all.spec.ts
rename to tests/eval-on-selector-all.spec.ts
index 564c19e71a..1b53f7ff98 100644
--- a/test/page/eval-on-selector-all.spec.ts
+++ b/tests/eval-on-selector-all.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work with css selector', async ({page, server}) => {
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');
diff --git a/test/page/eval-on-selector.spec.ts b/tests/eval-on-selector.spec.ts
similarity index 99%
rename from test/page/eval-on-selector.spec.ts
rename to tests/eval-on-selector.spec.ts
index 47fd64794e..c1188ace49 100644
--- a/test/page/eval-on-selector.spec.ts
+++ b/tests/eval-on-selector.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work with css selector', async ({page, server}) => {
await page.setContent('<section id="testAttribute">43543</section>');
diff --git a/test/page/jshandle-evaluate.spec.ts b/tests/jshandle-evaluate.spec.ts
similarity index 95%
rename from test/page/jshandle-evaluate.spec.ts
rename to tests/jshandle-evaluate.spec.ts
index ac5755b3d1..337dc5fc97 100644
--- a/test/page/jshandle-evaluate.spec.ts
+++ b/tests/jshandle-evaluate.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work with function', async ({page}) => {
const windowHandle = await page.evaluateHandle(() => {
diff --git a/test/page/jshandle-json-value.spec.ts b/tests/jshandle-json-value.spec.ts
similarity index 96%
rename from test/page/jshandle-json-value.spec.ts
rename to tests/jshandle-json-value.spec.ts
index f9af18643d..5cad2b592c 100644
--- a/test/page/jshandle-json-value.spec.ts
+++ b/tests/jshandle-json-value.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page}) => {
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
diff --git a/test/page/jshandle-properties.spec.ts b/tests/jshandle-properties.spec.ts
similarity index 97%
rename from test/page/jshandle-properties.spec.ts
rename to tests/jshandle-properties.spec.ts
index 46b77a8f49..3afc5f1986 100644
--- a/test/page/jshandle-properties.spec.ts
+++ b/tests/jshandle-properties.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import type { ElementHandle } from '../..';
+import { test as it, expect } from './config/pageTest';
+import type { ElementHandle } from '../index';
it('should work', async ({page}) => {
const aHandle = await page.evaluateHandle(() => ({
diff --git a/test/page/jshandle-to-string.spec.ts b/tests/jshandle-to-string.spec.ts
similarity index 98%
rename from test/page/jshandle-to-string.spec.ts
rename to tests/jshandle-to-string.spec.ts
index e99ae218cb..cec0417dfd 100644
--- a/test/page/jshandle-to-string.spec.ts
+++ b/tests/jshandle-to-string.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work for primitives', async ({page}) => {
const numberHandle = await page.evaluateHandle(() => 2);
diff --git a/test/page/page-add-init-script.spec.ts b/tests/page-add-init-script.spec.ts
similarity index 95%
rename from test/page/page-add-init-script.spec.ts
rename to tests/page-add-init-script.spec.ts
index 9fdf1880c2..4aaf68d061 100644
--- a/test/page/page-add-init-script.spec.ts
+++ b/tests/page-add-init-script.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
import path from 'path';
it('should evaluate before anything else on the page', async ({ page, server }) => {
@@ -27,7 +27,7 @@ it('should evaluate before anything else on the page', async ({ page, server })
});
it('should work with a path', async ({ page, server }) => {
- await page.addInitScript({ path: path.join(__dirname, '../assets/injectedfile.js') });
+ await page.addInitScript({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
await page.goto(server.PREFIX + '/tamperable.html');
expect(await page.evaluate(() => window['result'])).toBe(123);
});
diff --git a/test/page/page-add-script-tag.spec.ts b/tests/page-add-script-tag.spec.ts
similarity index 87%
rename from test/page/page-add-script-tag.spec.ts
rename to tests/page-add-script-tag.spec.ts
index eb093d5a60..184c4d9a14 100644
--- a/test/page/page-add-script-tag.spec.ts
+++ b/tests/page-add-script-tag.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
import path from 'path';
it('should throw an error if no options are provided', async ({page, server}) => {
@@ -44,7 +44,7 @@ it('should work with a url and type=module', async ({page, server}) => {
it('should work with a path and type=module', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, '../assets/es6/es6pathimport.js'), type: 'module' });
+ await page.addScriptTag({ path: path.join(__dirname, '../test/assets/es6/es6pathimport.js'), type: 'module' });
await page.waitForFunction('window.__es6injected');
expect(await page.evaluate(() => window['__es6injected'])).toBe(42);
});
@@ -69,16 +69,16 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
it('should work with a path', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
- const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, '../assets/injectedfile.js') });
+ const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
expect(scriptHandle.asElement()).not.toBeNull();
expect(await page.evaluate(() => window['__injected'])).toBe(42);
});
-it('should include sourceURL when path is provided', (test, { browserName }) => {
- test.skip(browserName === 'webkit');
-}, async ({page, server}) => {
+it('should include sourceURL when path is provided', async ({page, server, isWebKit}) => {
+ it.skip(isWebKit);
+
await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, '../assets/injectedfile.js') });
+ await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
const result = await page.evaluate(() => window['__injectedError'].stack);
expect(result).toContain(path.join('assets', 'injectedfile.js'));
});
@@ -98,9 +98,9 @@ it('should throw when added with content to the CSP page', async ({page, server}
expect(error).toBeTruthy();
});
-it('should throw when added with URL to the CSP page', test => {
- test.skip(process.env.PW_ANDROID_TESTS);
-}, async ({page, server}) => {
+it('should throw when added with URL to the CSP page', async ({page, server}) => {
+ it.skip(process.env.PW_ANDROID_TESTS);
+
await page.goto(server.PREFIX + '/csp.html');
let error = null;
await page.addScriptTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedfile.js' }).catch(e => error = e);
diff --git a/test/page/page-add-style-tag.spec.ts b/tests/page-add-style-tag.spec.ts
similarity index 90%
rename from test/page/page-add-style-tag.spec.ts
rename to tests/page-add-style-tag.spec.ts
index ac0fc16ebe..2bb22423f1 100644
--- a/test/page/page-add-style-tag.spec.ts
+++ b/tests/page-add-style-tag.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
import path from 'path';
it('should throw an error if no options are provided', async ({page, server}) => {
@@ -49,14 +49,14 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
it('should work with a path', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
- const styleHandle = await page.addStyleTag({ path: path.join(__dirname, '../assets/injectedstyle.css') });
+ const styleHandle = await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
expect(styleHandle.asElement()).not.toBeNull();
expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)');
});
it('should include sourceURL when path is provided', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
- await page.addStyleTag({ path: path.join(__dirname, '../assets/injectedstyle.css') });
+ await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
const styleHandle = await page.$('style');
const styleContent = await page.evaluate(style => style.innerHTML, styleHandle);
expect(styleContent).toContain(path.join('assets', 'injectedstyle.css'));
@@ -76,9 +76,9 @@ it('should throw when added with content to the CSP page', async ({page, server}
expect(error).toBeTruthy();
});
-it('should throw when added with URL to the CSP page', test => {
- test.skip(process.env.PW_ANDROID_TESTS);
-}, async ({page, server}) => {
+it('should throw when added with URL to the CSP page', async ({page, server}) => {
+ it.skip(process.env.PW_ANDROID_TESTS);
+
await page.goto(server.PREFIX + '/csp.html');
let error = null;
await page.addStyleTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedstyle.css' }).catch(e => error = e);
diff --git a/test/page/page-check.spec.ts b/tests/page-check.spec.ts
similarity index 98%
rename from test/page/page-check.spec.ts
rename to tests/page-check.spec.ts
index 3fa48fcc3b..6d85173370 100644
--- a/test/page/page-check.spec.ts
+++ b/tests/page-check.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+
+import { test as it, expect } from './config/pageTest';
it('should check the box', async ({page}) => {
await page.setContent(`<input id='checkbox' type='checkbox'></input>`);
diff --git a/test/page/page-click-react.spec.ts b/tests/page-click-react.spec.ts
similarity index 93%
rename from test/page/page-click-react.spec.ts
rename to tests/page-click-react.spec.ts
index 83b04c5b8c..d41c75ce5e 100644
--- a/test/page/page-click-react.spec.ts
+++ b/tests/page-click-react.spec.ts
@@ -14,15 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+
+import { test as it, expect } from './config/pageTest';
declare const renderComponent;
declare const e;
declare const MyButton;
-it('should report that selector does not match anymore', test => {
- test.fail(true);
-}, async ({page, server}) => {
+it('should report that selector does not match anymore', async ({page, server}) => {
+ it.fail();
+
await page.goto(server.PREFIX + '/react.html');
await page.evaluate(() => {
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2' })]));
@@ -41,9 +42,9 @@ it('should report that selector does not match anymore', test => {
expect(error.message).toContain('element does not match the selector anymore');
});
-it('should not retarget the handle when element is recycled', test => {
- test.fixme(true);
-}, async ({page, server}) => {
+it('should not retarget the handle when element is recycled', async ({page, server}) => {
+ it.fixme();
+
await page.goto(server.PREFIX + '/react.html');
await page.evaluate(() => {
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2', disabled: true })]));
@@ -70,9 +71,9 @@ it('should timeout when click opens alert', async ({page, server}) => {
await dialog.dismiss();
});
-it('should retarget when element is recycled during hit testing', test => {
- test.fixme(true);
-}, async ({page, server}) => {
+it('should retarget when element is recycled during hit testing', async ({page, server}) => {
+ it.fixme();
+
await page.goto(server.PREFIX + '/react.html');
await page.evaluate(() => {
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2' })]));
@@ -87,9 +88,9 @@ it('should retarget when element is recycled during hit testing', test => {
expect(await page.evaluate('window.button2')).toBe(undefined);
});
-it('should retarget when element is recycled before enabled check', test => {
- test.fixme(true);
-}, async ({page, server}) => {
+it('should retarget when element is recycled before enabled check', async ({page, server}) => {
+ it.fixme();
+
await page.goto(server.PREFIX + '/react.html');
await page.evaluate(() => {
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2', disabled: true })]));
diff --git a/test/page/page-click-scroll.spec.ts b/tests/page-click-scroll.spec.ts
similarity index 81%
rename from test/page/page-click-scroll.spec.ts
rename to tests/page-click-scroll.spec.ts
index 83ae91c2b2..1e9c781fc2 100644
--- a/test/page/page-click-scroll.spec.ts
+++ b/tests/page-click-scroll.spec.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { it } from '../fixtures';
+import { test as it } from './config/pageTest';
+
+it('should not hit scroll bar', async ({page, server, isWebKit, platform}) => {
+ it.fixme(isWebKit && platform === 'darwin');
+ it.skip(process.env.PW_ANDROID_TESTS);
-it('should not hit scroll bar', (test, { browserName, platform }) => {
- test.fixme(browserName === 'webkit' && platform === 'darwin');
- test.skip(process.env.PW_ANDROID_TESTS);
-}, async ({page, server}) => {
await page.setContent(`
<style>
.categories { width: 180px; display: flex; overflow-x: scroll; }
diff --git a/test/page/page-click-timeout-1.spec.ts b/tests/page-click-timeout-1.spec.ts
similarity index 90%
rename from test/page/page-click-timeout-1.spec.ts
rename to tests/page-click-timeout-1.spec.ts
index 34c753216f..8b17236696 100644
--- a/test/page/page-click-timeout-1.spec.ts
+++ b/tests/page-click-timeout-1.spec.ts
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
+
+it('should avoid side effects after timeout', async ({page, server, mode}) => {
+ it.skip(mode !== 'default');
-it('should avoid side effects after timeout', (test, { mode }) => {
- test.skip(mode !== 'default');
-}, async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))} as any).catch(e => e);
await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting.
diff --git a/test/page/page-click-timeout-2.spec.ts b/tests/page-click-timeout-2.spec.ts
similarity index 96%
rename from test/page/page-click-timeout-2.spec.ts
rename to tests/page-click-timeout-2.spec.ts
index 26770cdba7..6406671005 100644
--- a/test/page/page-click-timeout-2.spec.ts
+++ b/tests/page-click-timeout-2.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should timeout waiting for display:none to be gone', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/page/page-click-timeout-3.spec.ts b/tests/page-click-timeout-3.spec.ts
similarity index 95%
rename from test/page/page-click-timeout-3.spec.ts
rename to tests/page-click-timeout-3.spec.ts
index 1058602ae6..df0cf693aa 100644
--- a/test/page/page-click-timeout-3.spec.ts
+++ b/tests/page-click-timeout-3.spec.ts
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
+
+it('should fail when element jumps during hit testing', async ({page, mode}) => {
+ it.skip(mode !== 'default');
-it('should fail when element jumps during hit testing', (test, { mode }) => {
- test.skip(mode !== 'default');
-}, async ({page}) => {
await page.setContent('<button>Click me</button>');
let clicked = false;
const handle = await page.$('button');
diff --git a/test/page/page-click-timeout-4.spec.ts b/tests/page-click-timeout-4.spec.ts
similarity index 95%
rename from test/page/page-click-timeout-4.spec.ts
rename to tests/page-click-timeout-4.spec.ts
index 65a078311d..bd46f8f2ca 100644
--- a/test/page/page-click-timeout-4.spec.ts
+++ b/tests/page-click-timeout-4.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should timeout waiting for stable position', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/page/page-click.spec.ts b/tests/page-click.spec.ts
similarity index 98%
rename from test/page/page-click.spec.ts
rename to tests/page-click.spec.ts
index 3f7883b8c3..88cee57d51 100644
--- a/test/page/page-click.spec.ts
+++ b/tests/page-click.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame } from '../test/utils';
async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++)
@@ -296,9 +296,9 @@ it('should click the button inside an iframe', async ({page, server}) => {
expect(await frame.evaluate(() => window['result'])).toBe('Clicked');
});
-it('should click the button with fixed position inside an iframe', (test, { browserName }) => {
- test.fixme(browserName === 'chromium' || browserName === 'webkit');
-}, async ({page, server}) => {
+it('should click the button with fixed position inside an iframe', async ({page, server, isChromium, isWebKit}) => {
+ it.fixme(isChromium || isWebKit);
+
// @see https://github.com/GoogleChrome/puppeteer/issues/4110
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=986390
// @see https://chromium-review.googlesource.com/c/chromium/src/+/1742784
@@ -370,9 +370,9 @@ it('should click the button with em border with offset', async ({page, server, i
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 12 * 2 + 10 : 10);
});
-it('should click a very large button with offset', test => {
- test.skip(process.env.PWTESTREPORT);
-}, async ({page, server, isWebKit}) => {
+it('should click a very large button with offset', async ({page, server, isWebKit}) => {
+ it.skip(process.env.PWTESTREPORT);
+
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px');
await page.$eval('button', button => button.style.height = button.style.width = '2000px');
@@ -383,9 +383,9 @@ it('should click a very large button with offset', test => {
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 1910 + 8 : 1910);
});
-it('should click a button in scrolling container with offset', test => {
- test.skip(process.env.PWTESTREPORT);
-}, async ({page, server, isWebKit}) => {
+it('should click a button in scrolling container with offset', async ({page, server, isWebKit}) => {
+ it.skip(process.env.PWTESTREPORT);
+
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => {
const container = document.createElement('div');
diff --git a/test/page/page-dialog.spec.ts b/tests/page-dialog.spec.ts
similarity index 95%
rename from test/page/page-dialog.spec.ts
rename to tests/page-dialog.spec.ts
index 6afe627650..06fd02b3f1 100644
--- a/test/page/page-dialog.spec.ts
+++ b/tests/page-dialog.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should fire', async ({page, server}) => {
page.on('dialog', dialog => {
@@ -62,8 +62,7 @@ it('should dismiss the confirm prompt', async ({page}) => {
expect(result).toBe(false);
});
-it('should be able to close context with open alert', async ({context}) => {
- const page = await context.newPage();
+it('should be able to close context with open alert', async ({page}) => {
const alertPromise = page.waitForEvent('dialog');
await page.evaluate(() => {
setTimeout(() => alert('hello'), 0);
diff --git a/test/page/page-dispatchevent.spec.ts b/tests/page-dispatchevent.spec.ts
similarity index 99%
rename from test/page/page-dispatchevent.spec.ts
rename to tests/page-dispatchevent.spec.ts
index 1fb9f58ba6..2dcd3b7808 100644
--- a/test/page/page-dispatchevent.spec.ts
+++ b/tests/page-dispatchevent.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should dispatch click event', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/page/page-evaluate-handle.spec.ts b/tests/page-evaluate-handle.spec.ts
similarity index 98%
rename from test/page/page-evaluate-handle.spec.ts
rename to tests/page-evaluate-handle.spec.ts
index 7bb9c551f3..9f416e7b5b 100644
--- a/test/page/page-evaluate-handle.spec.ts
+++ b/tests/page-evaluate-handle.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page}) => {
const windowHandle = await page.evaluateHandle(() => window);
diff --git a/test/page/page-evaluate.spec.ts b/tests/page-evaluate.spec.ts
similarity index 97%
rename from test/page/page-evaluate.spec.ts
rename to tests/page-evaluate.spec.ts
index 87f6667e21..da1531d22d 100644
--- a/test/page/page-evaluate.spec.ts
+++ b/tests/page-evaluate.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({ page }) => {
const result = await page.evaluate(() => 7 * 3);
@@ -122,8 +122,8 @@ it('should return undefined for objects with symbols', async ({ page }) => {
it('should work with function shorthands', async ({ page }) => {
const a = {
- sum([a, b]) { return a + b; },
- async mult([a, b]) { return a * b; }
+ sum([a, b]: number[]) { return a + b; },
+ async mult([a, b]: number[]) { return a * b; }
};
expect(await page.evaluate(a.sum, [1, 2])).toBe(3);
expect(await page.evaluate(a.mult, [2, 4])).toBe(8);
@@ -415,9 +415,9 @@ it('should not throw an error when evaluation does a navigation', async ({ page,
expect(result).toEqual([42]);
});
-it('should not throw an error when evaluation does a synchronous navigation and returns an object', (test, { browserName }) => {
- test.fixme(browserName === 'webkit');
-}, async ({ page, server }) => {
+it('should not throw an error when evaluation does a synchronous navigation and returns an object', async ({ page, server, isWebKit }) => {
+ it.fixme(isWebKit);
+
// It is imporant to be on about:blank for sync reload.
const result = await page.evaluate(() => {
window.location.reload();
@@ -435,9 +435,9 @@ it('should not throw an error when evaluation does a synchronous navigation and
expect(result).toBe(undefined);
});
-it('should transfer 100Mb of data from page to node.js', (test, { mode }) => {
- test.skip(mode !== 'default');
-}, async ({ page }) => {
+it('should transfer 100Mb of data from page to node.js', async ({ mode, page }) => {
+ it.skip(mode !== 'default');
+
// This is too slow with wire.
const a = await page.evaluate(() => Array(100 * 1024 * 1024 + 1).join('a'));
expect(a.length).toBe(100 * 1024 * 1024);
diff --git a/test/page/page-event-console.spec.ts b/tests/page-event-console.spec.ts
similarity index 98%
rename from test/page/page-event-console.spec.ts
rename to tests/page-event-console.spec.ts
index 7413b01c76..be9928bc67 100644
--- a/test/page/page-event-console.spec.ts
+++ b/tests/page-event-console.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
import util from 'util';
it('should work', async ({page}) => {
diff --git a/test/page/page-event-crash.spec.ts b/tests/page-event-crash.spec.ts
similarity index 66%
rename from test/page/page-event-crash.spec.ts
rename to tests/page-event-crash.spec.ts
index ed5bb811b2..225ba6c861 100644
--- a/test/page/page-event-crash.spec.ts
+++ b/tests/page-event-crash.spec.ts
@@ -15,60 +15,65 @@
* limitations under the License.
*/
-import { it, expect, describe } from '../fixtures';
+import { test as it, expect, PageTestArgs } from './config/pageTest';
import * as os from 'os';
-function crash(page, toImpl, browserName) {
- if (browserName === 'chromium')
+function crash({ page, toImpl, browserName, platform, mode }: PageTestArgs) {
+ if (browserName === 'chromium') {
page.goto('chrome://crash').catch(e => {});
- else if (browserName === 'webkit')
+ } else if (browserName === 'webkit') {
+ it.skip(mode !== 'default');
+ it.fixme(platform === 'darwin' && parseInt(os.release(), 10) >= 20, 'Timing out after roll on BigSur');
toImpl(page)._delegate._session.send('Page.crash', {}).catch(e => {});
- else if (browserName === 'firefox')
+ } else if (browserName === 'firefox') {
+ it.skip(mode !== 'default');
toImpl(page)._delegate._session.send('Page.crash', {}).catch(e => {});
+ }
}
-describe('', (suite, { browserName, platform, mode }) => {
- suite.skip(mode !== 'default' && browserName !== 'chromium');
- const isBigSur = platform === 'darwin' && parseInt(os.release(), 10) >= 20;
- suite.fixme(isBigSur && browserName === 'webkit', 'Timing out after roll');
-}, () => {
- it('should emit crash event when page crashes', async ({page, browserName, toImpl}) => {
+it.describe('', () => {
+ it('should emit crash event when page crashes', async args => {
+ const { page } = args;
await page.setContent(`<div>This page should crash</div>`);
- crash(page, toImpl, browserName);
+ crash(args);
const crashedPage = await new Promise(f => page.on('crash', f));
expect(crashedPage).toBe(page);
});
- it('should throw on any action after page crashes', async ({page, browserName, toImpl}) => {
+ it('should throw on any action after page crashes', async args => {
+ const { page } = args;
await page.setContent(`<div>This page should crash</div>`);
- crash(page, toImpl, browserName);
+ crash(args);
await page.waitForEvent('crash');
const err = await page.evaluate(() => {}).then(() => null, e => e);
expect(err).toBeTruthy();
expect(err.message).toContain('crash');
});
- it('should cancel waitForEvent when page crashes', async ({page, browserName, toImpl}) => {
+ it('should cancel waitForEvent when page crashes', async args => {
+ const { page } = args;
await page.setContent(`<div>This page should crash</div>`);
const promise = page.waitForEvent('response').catch(e => e);
- crash(page, toImpl, browserName);
+ crash(args);
const error = await promise;
expect(error.message).toContain('Page crashed');
});
- it('should cancel navigation when page crashes', async ({page, browserName, toImpl, server}) => {
+ it('should cancel navigation when page crashes', async args => {
+ const { page, server } = args;
await page.setContent(`<div>This page should crash</div>`);
server.setRoute('/one-style.css', () => {});
const promise = page.goto(server.PREFIX + '/one-style.html').catch(e => e);
await page.waitForNavigation({ waitUntil: 'domcontentloaded' });
- crash(page, toImpl, browserName);
+ crash(args);
const error = await promise;
expect(error.message).toContain('Navigation failed because page crashed');
});
- it('should be able to close context when page crashes', async ({page, browserName, toImpl}) => {
+ it('should be able to close context when page crashes', async args => {
+ const { page } = args;
await page.setContent(`<div>This page should crash</div>`);
- crash(page, toImpl, browserName);
+ crash(args);
await page.waitForEvent('crash');
await page.context().close();
});
diff --git a/test/page/page-event-network.spec.ts b/tests/page-event-network.spec.ts
similarity index 98%
rename from test/page/page-event-network.spec.ts
rename to tests/page-event-network.spec.ts
index cfde05383b..8a4481ff5f 100644
--- a/test/page/page-event-network.spec.ts
+++ b/tests/page-event-network.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('Page.Events.Request', async ({page, server}) => {
const requests = [];
diff --git a/test/page/page-event-pageerror.spec.ts b/tests/page-event-pageerror.spec.ts
similarity index 84%
rename from test/page/page-event-pageerror.spec.ts
rename to tests/page-event-pageerror.spec.ts
index 3022029462..f0c930c9f8 100644
--- a/test/page/page-event-pageerror.spec.ts
+++ b/tests/page-event-pageerror.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should fire', async ({page, server, isWebKit}) => {
const [error] = await Promise.all([
@@ -31,9 +31,9 @@ it('should fire', async ({page, server, isWebKit}) => {
expect(error.stack).toBe(stack);
});
-it('should contain sourceURL', (test, { browserName }) => {
- test.fail(browserName === 'webkit');
-}, async ({page, server}) => {
+it('should contain sourceURL', async ({page, server, isWebKit}) => {
+ it.fail(isWebKit);
+
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
page.goto(server.PREFIX + '/error.html'),
@@ -57,9 +57,9 @@ it('should handle odd values', async ({page, isFirefox}) => {
}
});
-it('should handle object', (test, { browserName }) => {
- test.fixme(browserName === 'firefox');
-}, async ({page, isChromium}) => {
+it('should handle object', async ({page, isChromium, isFirefox}) => {
+ it.fixme(isFirefox);
+
// Firefox just does not report this error.
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
@@ -68,9 +68,9 @@ it('should handle object', (test, { browserName }) => {
expect(error.message).toBe(isChromium ? 'Object' : '[object Object]');
});
-it('should handle window', (test, { browserName }) => {
- test.fixme(browserName === 'firefox');
-}, async ({page, isChromium}) => {
+it('should handle window', async ({page, isChromium, isFirefox}) => {
+ it.fixme(isFirefox);
+
// Firefox just does not report this error.
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
diff --git a/test/page/page-event-popup.spec.ts b/tests/page-event-popup.spec.ts
similarity index 96%
rename from test/page/page-event-popup.spec.ts
rename to tests/page-event-popup.spec.ts
index 565a1f0c94..7c64c860a8 100644
--- a/test/page/page-event-popup.spec.ts
+++ b/tests/page-event-popup.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page}) => {
const [popup] = await Promise.all([
@@ -46,9 +46,9 @@ it('should emit for immediately closed popups', async ({page}) => {
expect(popup).toBeTruthy();
});
-it('should emit for immediately closed popups 2', (test, {browserName, video}) => {
- test.fixme(browserName === 'firefox' && video);
-}, async ({page, server}) => {
+it('should emit for immediately closed popups 2', async ({page, server, isFirefox, video}) => {
+ it.fixme(isFirefox && video);
+
await page.goto(server.EMPTY_PAGE);
const [popup] = await Promise.all([
page.waitForEvent('popup'),
diff --git a/test/page/page-event-request.spec.ts b/tests/page-event-request.spec.ts
similarity index 92%
rename from test/page/page-event-request.spec.ts
rename to tests/page-event-request.spec.ts
index 3d856c0109..30bd252540 100644
--- a/test/page/page-event-request.spec.ts
+++ b/tests/page-event-request.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame } from '../test/utils';
it('should fire for navigation requests', async ({page, server}) => {
const requests = [];
@@ -41,9 +41,9 @@ it('should fire for fetches', async ({page, server}) => {
expect(requests.length).toBe(2);
});
-it('should report requests and responses handled by service worker', test => {
- test.fixme(process.env.PW_ANDROID_TESTS);
-}, async ({page, server}) => {
+it('should report requests and responses handled by service worker', async ({page, server}) => {
+ it.fixme(process.env.PW_ANDROID_TESTS);
+
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
await page.evaluate(() => window['activationPromise']);
const [swResponse, request] = await Promise.all([
diff --git a/test/page/page-fill.spec.ts b/tests/page-fill.spec.ts
similarity index 93%
rename from test/page/page-fill.spec.ts
rename to tests/page-fill.spec.ts
index e1bb839692..674c6fbb60 100644
--- a/test/page/page-fill.spec.ts
+++ b/tests/page-fill.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
async function giveItAChanceToFill(page) {
for (let i = 0; i < 5; i++)
@@ -90,9 +90,9 @@ it('should fill date input after clicking', async ({page, server}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02');
});
-it('should throw on incorrect date', (test, { browserName }) => {
- test.skip(browserName === 'webkit', 'WebKit does not support date inputs');
-}, async ({page}) => {
+it('should throw on incorrect date', async ({page, isWebKit}) => {
+ it.skip(isWebKit, 'WebKit does not support date inputs');
+
await page.setContent('<input type=date>');
const error = await page.fill('input', '2020-13-05').catch(e => e);
expect(error.message).toContain('Malformed value');
@@ -110,9 +110,9 @@ it('should fill month input', async ({page}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-07');
});
-it('should throw on incorrect month', (test, { browserName }) => {
- test.skip(browserName !== 'chromium', 'Only Chromium supports month inputs');
-}, async ({page}) => {
+it('should throw on incorrect month', async ({page, isChromium}) => {
+ it.skip(!isChromium, 'Only Chromium supports month inputs');
+
await page.setContent('<input type=month>');
const error = await page.fill('input', '2020-13').catch(e => e);
expect(error.message).toContain('Malformed value');
@@ -124,17 +124,17 @@ it('should fill week input', async ({page}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-W50');
});
-it('should throw on incorrect week', (test, { browserName }) => {
- test.skip(browserName !== 'chromium', 'Only Chromium supports week inputs');
-}, async ({page}) => {
+it('should throw on incorrect week', async ({page, isChromium}) => {
+ it.skip(!isChromium, 'Only Chromium supports week inputs');
+
await page.setContent('<input type=week>');
const error = await page.fill('input', '2020-123').catch(e => e);
expect(error.message).toContain('Malformed value');
});
-it('should throw on incorrect time', (test, { browserName }) => {
- test.skip(browserName === 'webkit', 'WebKit does not support time inputs');
-}, async ({page}) => {
+it('should throw on incorrect time', async ({page, isWebKit}) => {
+ it.skip(isWebKit, 'WebKit does not support time inputs');
+
await page.setContent('<input type=time>');
const error = await page.fill('input', '25:05').catch(e => e);
expect(error.message).toContain('Malformed value');
@@ -146,9 +146,9 @@ it('should fill datetime-local input', async ({page, server}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02T05:15');
});
-it('should throw on incorrect datetime-local', (test, { browserName }) => {
- test.skip(browserName !== 'chromium', 'Only Chromium supports datetime-local inputs');
-}, async ({page, server}) => {
+it('should throw on incorrect datetime-local', async ({page, server, isChromium}) => {
+ it.skip(!isChromium, 'Only Chromium supports datetime-local inputs');
+
await page.setContent('<input type=datetime-local>');
const error = await page.fill('input', 'abc').catch(e => e);
expect(error.message).toContain('Malformed value');
diff --git a/test/page/page-route.spec.ts b/tests/page-route.spec.ts
similarity index 93%
rename from test/page/page-route.spec.ts
rename to tests/page-route.spec.ts
index a706596970..687bbbb524 100644
--- a/test/page/page-route.spec.ts
+++ b/tests/page-route.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should intercept', async ({page, server}) => {
let intercepted = false;
@@ -123,10 +123,12 @@ it('should contain referer header', async ({page, server}) => {
expect(requests[1].headers().referer).toContain('/one-style.html');
});
-it('should properly return navigation response when URL has cookies', async ({context, page, server}) => {
+it('should properly return navigation response when URL has cookies', async ({page, server}) => {
+ it.skip(process.env.PW_ANDROID_TESTS);
+
// Setup cookie.
await page.goto(server.EMPTY_PAGE);
- await context.addCookies([{ url: server.EMPTY_PAGE, name: 'foo', value: 'bar'}]);
+ await page.context().addCookies([{ url: server.EMPTY_PAGE, name: 'foo', value: 'bar'}]);
// Setup request interception.
await page.route('**/*', route => route.continue());
@@ -159,9 +161,9 @@ it('should work with redirect inside sync XHR', async ({page, server}) => {
expect(status).toBe(200);
});
-it('should pause intercepted XHR until continue', (test, { browserName}) => {
- test.fixme(browserName === 'webkit', 'Redirected request is not paused in WebKit');
-}, async ({page, server}) => {
+it('should pause intercepted XHR until continue', async ({page, server, isWebKit}) => {
+ it.fixme(isWebKit, 'Redirected request is not paused in WebKit');
+
await page.goto(server.EMPTY_PAGE);
let resolveRoute;
const routePromise = new Promise(r => resolveRoute = r);
@@ -446,9 +448,9 @@ it('should intercept main resource during cross-process navigation', async ({pag
expect(intercepted).toBe(true);
});
-it('should fulfill with redirect status', (test, { browserName, headful}) => {
- test.fixme(browserName === 'webkit', 'in WebKit the redirects are handled by the network stack and we intercept before');
-}, async ({page, server}) => {
+it('should fulfill with redirect status', async ({page, server, isWebKit}) => {
+ it.fixme(isWebKit, 'in WebKit the redirects are handled by the network stack and we intercept before');
+
await page.goto(server.PREFIX + '/title.html');
server.setRoute('/final', (req, res) => res.end('foo'));
await page.route('**/*', async (route, request) => {
@@ -469,9 +471,9 @@ it('should fulfill with redirect status', (test, { browserName, headful}) => {
expect(text).toBe('foo');
});
-it('should not fulfill with redirect status', (test, { browserName, headful}) => {
- test.skip(browserName !== 'webkit', 'we should support fulfill with redirect in webkit and delete this test');
-}, async ({page, server}) => {
+it('should not fulfill with redirect status', async ({page, server, isWebKit}) => {
+ it.skip(!isWebKit, 'we should support fulfill with redirect in webkit and delete this test');
+
await page.goto(server.PREFIX + '/empty.html');
let status;
@@ -532,9 +534,9 @@ it('should support cors with GET', async ({page, server}) => {
}
});
-it('should support cors with POST', (test, { browserName, browserChannel }) => {
- test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
-}, async ({page, server}) => {
+it('should support cors with POST', async ({page, server, isChromium, browserChannel}) => {
+ it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
+
await page.goto(server.EMPTY_PAGE);
await page.route('**/cars', async route => {
await route.fulfill({
@@ -556,9 +558,9 @@ it('should support cors with POST', (test, { browserName, browserChannel }) => {
expect(resp).toEqual(['electric', 'gas']);
});
-it('should support cors with credentials', (test, { browserName, browserChannel }) => {
- test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
-}, async ({page, server}) => {
+it('should support cors with credentials', async ({page, server, isChromium, browserChannel}) => {
+ it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
+
await page.goto(server.EMPTY_PAGE);
await page.route('**/cars', async route => {
await route.fulfill({
@@ -616,9 +618,9 @@ it('should reject cors with disallowed credentials', async ({page, server}) => {
expect(error).toBeTruthy();
});
-it('should support cors for different methods', (test, {browserName, browserChannel}) => {
- test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
-}, async ({page, server}) => {
+it('should support cors for different methods', async ({page, server, isChromium, browserChannel}) => {
+ it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
+
await page.goto(server.EMPTY_PAGE);
await page.route('**/cars', async (route, request) => {
await route.fulfill({
diff --git a/test/page/page-select-option.spec.ts b/tests/page-select-option.spec.ts
similarity index 99%
rename from test/page/page-select-option.spec.ts
rename to tests/page-select-option.spec.ts
index 0c52a8402c..8c02d142ee 100644
--- a/test/page/page-select-option.spec.ts
+++ b/tests/page-select-option.spec.ts
@@ -15,8 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-
+import { test as it, expect } from './config/pageTest';
async function giveItAChanceToResolve(page) {
for (let i = 0; i < 5; i++)
diff --git a/test/page/page-set-content.spec.ts b/tests/page-set-content.spec.ts
similarity index 98%
rename from test/page/page-set-content.spec.ts
rename to tests/page-set-content.spec.ts
index aaeaf80119..3756285950 100644
--- a/test/page/page-set-content.spec.ts
+++ b/tests/page-set-content.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';
diff --git a/test/page/page-set-extra-http-headers.spec.ts b/tests/page-set-extra-http-headers.spec.ts
similarity index 87%
rename from test/page/page-set-extra-http-headers.spec.ts
rename to tests/page-set-extra-http-headers.spec.ts
index 011c330bf7..47ec217dde 100644
--- a/test/page/page-set-extra-http-headers.spec.ts
+++ b/tests/page-set-extra-http-headers.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page, server}) => {
await page.setExtraHTTPHeaders({
@@ -53,13 +53,11 @@ it('should work with extra headers from browser context', async ({page, server})
expect(request.headers['foo']).toBe('bar');
});
-it('should throw for non-string header values', async ({browser, page}) => {
+it('should throw for non-string header values', async ({page}) => {
// @ts-expect-error headers must be strings
const error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);
expect(error1.message).toContain('Expected value of header "foo" to be String, but "number" is found.');
// @ts-expect-error headers must be strings
const error2 = await page.context().setExtraHTTPHeaders({ 'foo': true }).catch(e => e);
expect(error2.message).toContain('Expected value of header "foo" to be String, but "boolean" is found.');
- const error3 = await browser.newContext({ extraHTTPHeaders: { 'foo': null } }).catch(e => e);
- expect(error3.message).toContain('Expected value of header "foo" to be String, but "object" is found.');
});
diff --git a/test/page/page-set-input-files.spec.ts b/tests/page-set-input-files.spec.ts
similarity index 93%
rename from test/page/page-set-input-files.spec.ts
rename to tests/page-set-input-files.spec.ts
index 8f60306687..fd1a6fe1a7 100644
--- a/test/page/page-set-input-files.spec.ts
+++ b/tests/page-set-input-files.spec.ts
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
import path from 'path';
import fs from 'fs';
import formidable from 'formidable';
-const FILE_TO_UPLOAD = path.join(__dirname, '../assets/file-to-upload.txt');
+const FILE_TO_UPLOAD = path.join(__dirname, '../test/assets/file-to-upload.txt');
it('should upload the file', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/fileupload.html');
@@ -39,7 +39,7 @@ it('should upload the file', async ({page, server}) => {
it('should work', async ({page}) => {
await page.setContent(`<input type=file>`);
- await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
+ await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -120,9 +120,9 @@ it('should work when file input is not attached to DOM', async ({page, server})
expect(content).toBe('contents of the file');
});
-it('should not throw when filechooser belongs to iframe', (test, { browserName }) => {
- test.skip(browserName === 'firefox', 'Firefox ignores filechooser from child frame');
-}, async ({page, server}) => {
+it('should not throw when filechooser belongs to iframe', async ({page, server, isFirefox}) => {
+ it.skip(isFirefox, 'Firefox ignores filechooser from child frame');
+
await page.goto(server.PREFIX + '/frames/one-frame.html');
const frame = page.mainFrame().childFrames()[0];
await frame.setContent(`
@@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {
server.setCSP('/empty.html', 'default-src "none"');
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<input type=file>`);
- await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
+ await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
<input type="file" name="file2">
<input type="submit" value="Submit">
</form>`);
- await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));
- await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));
+ await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../test/assets/file-to-upload.txt'));
+ await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../test/assets/pptr.png'));
await Promise.all([
page.click('input[type=submit]'),
server.waitForRequest('/upload'),
@@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {
expect(file1.name).toBe('file-to-upload.txt');
expect(file1.type).toBe('text/plain');
expect(fs.readFileSync(file1.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());
+ fs.readFileSync(path.join(__dirname, '../test/assets/file-to-upload.txt')).toString());
expect(file2.name).toBe('pptr.png');
expect(file2.type).toBe('image/png');
expect(fs.readFileSync(file2.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());
+ fs.readFileSync(path.join(__dirname, '../test/assets/pptr.png')).toString());
});
it('should be able to read selected file', async ({page, server}) => {
@@ -307,8 +307,8 @@ it('should not accept multiple files for single-file input', async ({page, serve
]);
let error = null;
await fileChooser.setFiles([
- path.relative(process.cwd(), __dirname + '/assets/file-to-upload.txt'),
- path.relative(process.cwd(), __dirname + '/assets/pptr.png')
+ path.join(__dirname, '../test/assets/file-to-upload.txt'),
+ path.join(__dirname, '../test/assets/pptr.png')
]).catch(e => error = e);
expect(error).not.toBe(null);
});
diff --git a/test/page/page-wait-for-function.spec.ts b/tests/page-wait-for-function.spec.ts
similarity index 99%
rename from test/page/page-wait-for-function.spec.ts
rename to tests/page-wait-for-function.spec.ts
index 273ff1abf8..87b5e40d21 100644
--- a/test/page/page-wait-for-function.spec.ts
+++ b/tests/page-wait-for-function.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should timeout', async ({page}) => {
const startTime = Date.now();
diff --git a/test/page/page-wait-for-load-state.spec.ts b/tests/page-wait-for-load-state.spec.ts
similarity index 92%
rename from test/page/page-wait-for-load-state.spec.ts
rename to tests/page-wait-for-load-state.spec.ts
index 3c5e162f68..252e957f45 100644
--- a/test/page/page-wait-for-load-state.spec.ts
+++ b/tests/page-wait-for-load-state.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import type { Route } from '../..';
+import { test as it, expect } from './config/pageTest';
+import type { Route } from '../index';
it('should pick up ongoing navigation', async ({page, server}) => {
let response = null;
@@ -57,7 +57,7 @@ it('should resolve immediately if load state matches', async ({page, server}) =>
await page.waitForLoadState('domcontentloaded');
});
-it('should work with pages that have loaded before being connected to', async ({page, context, server}) => {
+it('should work with pages that have loaded before being connected to', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
const [popup] = await Promise.all([
page.waitForEvent('popup'),
@@ -82,7 +82,7 @@ it('should wait for load state of empty url popup', async ({page, isFirefox}) =>
expect(await popup.evaluate(() => document.readyState)).toBe(isFirefox ? 'uninitialized' : 'complete');
});
-it('should wait for load state of about:blank popup ', async ({browser, page}) => {
+it('should wait for load state of about:blank popup ', async ({page}) => {
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.evaluate(() => window.open('about:blank') && 1),
@@ -91,7 +91,7 @@ it('should wait for load state of about:blank popup ', async ({browser, page}) =
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
});
-it('should wait for load state of about:blank popup with noopener ', async ({browser, page}) => {
+it('should wait for load state of about:blank popup with noopener ', async ({page}) => {
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.evaluate(() => window.open('about:blank', null, 'noopener') && 1),
@@ -100,7 +100,7 @@ it('should wait for load state of about:blank popup with noopener ', async ({bro
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
});
-it('should wait for load state of popup with network url ', async ({browser, page, server}) => {
+it('should wait for load state of popup with network url ', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
const [popup] = await Promise.all([
page.waitForEvent('popup'),
@@ -110,7 +110,7 @@ it('should wait for load state of popup with network url ', async ({browser, pag
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
});
-it('should wait for load state of popup with network url and noopener ', async ({browser, page, server}) => {
+it('should wait for load state of popup with network url and noopener ', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
const [popup] = await Promise.all([
page.waitForEvent('popup'),
@@ -120,7 +120,7 @@ it('should wait for load state of popup with network url and noopener ', async (
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
});
-it('should work with clicking target=_blank', async ({browser, page, server}) => {
+it('should work with clicking target=_blank', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
await page.setContent('<a target=_blank rel="opener" href="/one-style.html">yo</a>');
const [popup] = await Promise.all([
@@ -131,10 +131,10 @@ it('should work with clicking target=_blank', async ({browser, page, server}) =>
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
});
-it('should wait for load state of newPage', async ({browser, context, page, server}) => {
+it('should wait for load state of newPage', async ({page, server}) => {
const [newPage] = await Promise.all([
- context.waitForEvent('page'),
- context.newPage(),
+ page.context().waitForEvent('page'),
+ page.context().newPage(),
]);
await newPage.waitForLoadState();
expect(await newPage.evaluate(() => document.readyState)).toBe('complete');
diff --git a/test/page/page-wait-for-navigation.spec.ts b/tests/page-wait-for-navigation.spec.ts
similarity index 98%
rename from test/page/page-wait-for-navigation.spec.ts
rename to tests/page-wait-for-navigation.spec.ts
index d381bc5f63..f8124992e0 100644
--- a/test/page/page-wait-for-navigation.spec.ts
+++ b/tests/page-wait-for-navigation.spec.ts
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import type { Frame } from '../../index';
-import { expectedSSLError } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import type { Frame } from '../index';
+import { expectedSSLError } from '../test/utils';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page/page-wait-for-request.spec.ts b/tests/page-wait-for-request.spec.ts
similarity index 98%
rename from test/page/page-wait-for-request.spec.ts
rename to tests/page-wait-for-request.spec.ts
index 0fd97770bf..77668e3386 100644
--- a/test/page/page-wait-for-request.spec.ts
+++ b/tests/page-wait-for-request.spec.ts
@@ -15,8 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-
+import { test as it, expect } from './config/pageTest';
import vm from 'vm';
it('should work', async ({page, server}) => {
diff --git a/test/page/page-wait-for-response.spec.ts b/tests/page-wait-for-response.spec.ts
similarity index 98%
rename from test/page/page-wait-for-response.spec.ts
rename to tests/page-wait-for-response.spec.ts
index c83f7dab70..2c352fe1f4 100644
--- a/test/page/page-wait-for-response.spec.ts
+++ b/tests/page-wait-for-response.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page/page-wait-for-selector-1.spec.ts b/tests/page-wait-for-selector-1.spec.ts
similarity index 98%
rename from test/page/page-wait-for-selector-1.spec.ts
rename to tests/page-wait-for-selector-1.spec.ts
index 3d8440996c..ab3b08b157 100644
--- a/test/page/page-wait-for-selector-1.spec.ts
+++ b/tests/page-wait-for-selector-1.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame, detachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame, detachFrame } from '../test/utils';
async function giveItTimeToLog(frame) {
await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));
diff --git a/test/page/page-wait-for-selector-2.spec.ts b/tests/page-wait-for-selector-2.spec.ts
similarity index 99%
rename from test/page/page-wait-for-selector-2.spec.ts
rename to tests/page-wait-for-selector-2.spec.ts
index 9cd795b999..fe1f74c60a 100644
--- a/test/page/page-wait-for-selector-2.spec.ts
+++ b/tests/page-wait-for-selector-2.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
-import { attachFrame, detachFrame } from '../utils';
+import { test as it, expect } from './config/pageTest';
+import { attachFrame, detachFrame } from '../test/utils';
const addElement = tag => document.body.appendChild(document.createElement(tag));
diff --git a/test/page/page-wait-for-url.spec.ts b/tests/page-wait-for-url.spec.ts
similarity index 98%
rename from test/page/page-wait-for-url.spec.ts
rename to tests/page-wait-for-url.spec.ts
index 9894461e9e..badb32d795 100644
--- a/test/page/page-wait-for-url.spec.ts
+++ b/tests/page-wait-for-url.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from '../fixtures';
+import { test as it, expect } from './config/pageTest';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);