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: remove main index.js from playwright-core (#2178)
Pavel Feldmanc5b0baacd1fe
diff --git a/browsers.json b/browsers.jsondeleted file mode 100644index 31dea6dedb..0000000000--- a/browsers.json+++ /dev/null@@ -1,16 +0,0 @@-{- "browsers": [- {- "name": "chromium",- "revision": "764964"- },- {- "name": "firefox",- "revision": "1093"- },- {- "name": "webkit",- "revision": "1224"- }- ]-}diff --git a/index.js b/index-for-dev.jssimilarity index 75%rename from index.jsrename to index-for-dev.jsindex bcc6ecaa3d..8194796c7f 100644--- a/index.js+++ b/index-for-dev.js@@ -15,5 +15,7 @@*/const { Playwright } = require('./lib/server/playwright');+const path = require('path');-module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);+const playwrightRoot = path.join(__dirname, 'packages', 'playwright');+module.exports = new Playwright(playwrightRoot, require(path.join(playwrightRoot, 'browsers.json'))['browsers']);diff --git a/install-from-github.js b/install-from-github.jsindex 77f5ed4bcf..50213de973 100644--- a/install-from-github.js+++ b/install-from-github.js@@ -64,9 +64,10 @@ async function downloadAllBrowsersAndGenerateProtocolTypes() {const { installBrowsersWithProgressBar } = require('./lib/install/installer');const protocolGenerator = require('./utils/protocol-types-generator');const browserPaths = require('./lib/install/browserPaths');- const browsersPath = browserPaths.browsersPath(__dirname);- const browsers = require('./browsers.json')['browsers'];- await installBrowsersWithProgressBar(__dirname);+ const playwrightRoot = path.join(__dirname, 'packages', 'playwright');+ const browsersPath = browserPaths.browsersPath(playwrightRoot);+ const browsers = require(path.join(playwrightRoot, 'browsers.json'))['browsers'];+ await installBrowsersWithProgressBar(playwrightRoot);for (const browser of browsers) {const browserPath = browserPaths.browserDirectory(browsersPath, browser);await protocolGenerator.generateProtocol(browser.name, browserPaths.executablePath(browserPath, browser)).catch(console.warn);diff --git a/package.json b/package.jsonindex 63c2503b23..eeb621b696 100644--- a/package.json+++ b/package.json@@ -7,7 +7,6 @@"engines": {"node": ">=10.15.0"},- "main": "index.js","scripts": {"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js","ftest": "cross-env BROWSER=firefox node --unhandled-rejections=strict test/test.js",diff --git a/test/fixtures.spec.js b/test/fixtures.spec.jsindex 074e4a7422..4b44bc283f 100644--- a/test/fixtures.spec.js+++ b/test/fixtures.spec.js@@ -26,7 +26,7 @@ async function testSignal(state, action, exitOnClose) {handleSIGHUP: true,executablePath: state.browserType.executablePath(),});- const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), state.playwrightPath, state.browserType.name(), JSON.stringify(options), exitOnClose ? 'true' : '']);+ const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), path.join(state.playwrightPath, 'index-for-dev'), state.browserType.name(), JSON.stringify(options), exitOnClose ? 'true' : '']);let wsEndPointCallback;const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);let output = '';diff --git a/test/fixtures/closeme.js b/test/fixtures/closeme.jsindex f1f3f2c422..10790c7d89 100644--- a/test/fixtures/closeme.js+++ b/test/fixtures/closeme.js@@ -1,6 +1,6 @@(async() => {- const [, , playwrightRoot, browserType, options, exitOnClose] = process.argv;- const browserServer = await require(playwrightRoot)[browserType].launchServer(JSON.parse(options));+ const [, , playwrightIndex, browserType, options, exitOnClose] = process.argv;+ const browserServer = await require(playwrightIndex)[browserType].launchServer(JSON.parse(options));browserServer.on('close', (exitCode, signal) => {console.log(`browserClose:${exitCode}:${signal}:browserClose`);if (exitOnClose)diff --git a/test/test.js b/test/test.jsindex 844f30c55c..33a85a58c1 100644--- a/test/test.js+++ b/test/test.js@@ -16,6 +16,7 @@*/const fs = require('fs');+const path = require('path');const TestRunner = require('../utils/testrunner/');const {Environment} = require('../utils/testrunner/Test');@@ -72,7 +73,7 @@ function collect(browserNames) {// TODO: this should be a preinstalled playwright by default.const playwrightPath = config.playwrightPath;- const playwright = require(playwrightPath);+ const playwright = require(path.join(playwrightPath, 'index-for-dev'));const { setUnderTest } = require(require('path').join(playwrightPath, 'lib/helper.js'));setUnderTest();diff --git a/test/types.d.ts b/test/types.d.tsindex b92944add8..5582579070 100644--- a/test/types.d.ts+++ b/test/types.d.ts@@ -48,8 +48,8 @@ interface TestSetup<STATE> {MAC: boolean;LINUX: boolean;WIN: boolean;- playwright: typeof import('../index');- browserType: import('../index').BrowserType<import('../index').Browser>;+ playwright: typeof import('../index-for-dev');+ browserType: import('../index-for-dev').BrowserType<import('../index-for-dev').Browser>;selectors: import('../src/selectors').Selectors;expect<T>(value: T): Expect<T>;defaultBrowserOptions: import('../src/server/browserType').LaunchOptions;@@ -65,16 +65,16 @@ type TestState = {};type BrowserState = TestState & {- browser: import('../index').Browser;- browserServer: import('../index').BrowserServer;+ browser: import('../index-for-dev').Browser;+ browserServer: import('../index-for-dev').BrowserServer;};type PageState = BrowserState & {- context: import('../index').BrowserContext;- page: import('../index').Page;+ context: import('../index-for-dev').BrowserContext;+ page: import('../index-for-dev').Page;};type ChromiumPageState = PageState & {- browser: import('../index').ChromiumBrowser;+ browser: import('../index-for-dev').ChromiumBrowser;};type TestSuite = (setup: TestSetup<TestState>) => void;type BrowserTestSuite = (setup: TestSetup<BrowserState>) => void;diff --git a/utils/doclint/check_public_api/test/test.js b/utils/doclint/check_public_api/test/test.jsindex 54414ff229..8864773a4a 100644--- a/utils/doclint/check_public_api/test/test.js+++ b/utils/doclint/check_public_api/test/test.js@@ -15,7 +15,7 @@*/const path = require('path');-const playwright = require('../../../..');+const playwright = require('../../../../index-for-dev');const checkPublicAPI = require('..');const Source = require('../../Source');const mdBuilder = require('../MDBuilder');diff --git a/utils/doclint/cli.js b/utils/doclint/cli.jsindex 382a9feb24..bc5580d05c 100755--- a/utils/doclint/cli.js+++ b/utils/doclint/cli.js@@ -15,7 +15,7 @@* limitations under the License.*/-const playwright = require('../../index.js');+const playwright = require('../../index-for-dev');const path = require('path');const Source = require('./Source');const Message = require('./Message');diff --git a/utils/generate_types/index.js b/utils/generate_types/index.jsindex 48d2dc0b27..1997fecf17 100644--- a/utils/generate_types/index.js+++ b/utils/generate_types/index.js@@ -17,7 +17,7 @@//@ts-checkconst path = require('path');const Source = require('../doclint/Source');-const {chromium} = require('../../index');+const {chromium} = require('../../index-for-dev');const Documentation = require('../doclint/check_public_api/Documentation');const PROJECT_DIR = path.join(__dirname, '..', '..');const fs = require('fs');diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.tsindex 8df240b5ac..23c648a06a 100644--- a/utils/generate_types/test/test.ts+++ b/utils/generate_types/test/test.ts@@ -15,6 +15,7 @@*/import * as playwright from '../../../index';+type AssertType<T, S> = S extends T ? AssertNotAny<S> : false;type AssertNotAny<S> = {notRealProperty: number} extends S ? false : true;diff --git a/utils/protocol-types-generator/index.js b/utils/protocol-types-generator/index.jsindex 3aeb8bcd52..f539426c60 100644--- a/utils/protocol-types-generator/index.js+++ b/utils/protocol-types-generator/index.js@@ -17,7 +17,7 @@ async function generateProtocol(name, executablePath) {async function generateChromiumProtocol(executablePath) {const outputPath = path.join(__dirname, '..', '..', 'src', 'chromium', 'protocol.ts');- const playwright = await require('../../index').chromium;+ const playwright = await require('../../index-for-dev').chromium;const defaultArgs = playwright._defaultArgs.bind(playwright);playwright._defaultArgs = (...args) => {const result = defaultArgs(...args);