Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: make generate_types not depend on the source (#5040)
Dmitry Gozman17e953c2d8bd
diff --git a/docs/src/cli.md b/docs/src/cli.mdindex b416cce794..dba4afa7dd 100644--- a/docs/src/cli.md+++ b/docs/src/cli.md@@ -95,7 +95,7 @@ $ python -m playwright wk example.com```### Emulate devices-`open` can emulate mobile and tablet devices ([see all devices](https://github.com/microsoft/playwright/blob/master/src/server/deviceDescriptors.ts)).+`open` can emulate mobile and tablet devices from the [`playwright.devices`](https://playwright.dev/docs/api/class-playwright#playwrightdevices) list.```sh js# Emulate iPhone 11.diff --git a/src/dispatchers/playwrightDispatcher.ts b/src/dispatchers/playwrightDispatcher.tsindex 92fa3716af..3c1f27c4e3 100644--- a/src/dispatchers/playwrightDispatcher.ts+++ b/src/dispatchers/playwrightDispatcher.ts@@ -15,17 +15,18 @@*/import * as channels from '../protocol/channels';-import { DeviceDescriptors } from '../server/deviceDescriptors';import { Playwright } from '../server/playwright';import { AndroidDispatcher } from './androidDispatcher';import { BrowserTypeDispatcher } from './browserTypeDispatcher';import { Dispatcher, DispatcherScope } from './dispatcher';import { ElectronDispatcher } from './electronDispatcher';import { SelectorsDispatcher } from './selectorsDispatcher';+import * as types from '../server/types';export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.PlaywrightInitializer> implements channels.PlaywrightChannel {constructor(scope: DispatcherScope, playwright: Playwright) {- const deviceDescriptors = Object.entries(DeviceDescriptors)+ const descriptors = require('../server/deviceDescriptors') as types.Devices;+ const deviceDescriptors = Object.entries(descriptors).map(([name, descriptor]) => ({ name, descriptor }));super(scope, playwright, 'Playwright', {chromium: new BrowserTypeDispatcher(scope, playwright.chromium),diff --git a/src/server/deviceDescriptors.ts b/src/server/deviceDescriptors.jssimilarity index 99%rename from src/server/deviceDescriptors.tsrename to src/server/deviceDescriptors.jsindex d6018b94b5..bea4109e50 100644--- a/src/server/deviceDescriptors.ts+++ b/src/server/deviceDescriptors.js@@ -15,9 +15,10 @@* limitations under the License.*/-import * as types from './types';--export const DeviceDescriptors: types.Devices = {+/**+ * @type {import('./types').Devices}+ */+module.exports = {'Blackberry PlayBook': {'userAgent': 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+','viewport': {diff --git a/test/launcher.spec.ts b/test/launcher.spec.tsindex fc6fcbad53..a7f8bd1a12 100644--- a/test/launcher.spec.ts+++ b/test/launcher.spec.ts@@ -23,7 +23,7 @@ it('should require top-level Errors', async ({}) => {});it('should require top-level DeviceDescriptors', async ({playwright}) => {- const Devices = require('../lib/server/deviceDescriptors.js').DeviceDescriptors;+ const Devices = require('../lib/server/deviceDescriptors.js');expect(Devices['iPhone 6']).toBeTruthy();expect(Devices['iPhone 6']).toEqual(playwright.devices['iPhone 6']);});diff --git a/utils/generate_types/index.js b/utils/generate_types/index.jsindex 646fabdf83..9d5a6e3bd6 100644--- a/utils/generate_types/index.js+++ b/utils/generate_types/index.js@@ -17,7 +17,7 @@//@ts-checkconst path = require('path');const os = require('os');-const {devices} = require('../..');+const devices = require('../../src/server/deviceDescriptors');const Documentation = require('../doclint/documentation');const PROJECT_DIR = path.join(__dirname, '..', '..');const fs = require('fs');