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
fix(types): properly export typescript types from packages (#2364)
Andrey Lushnikov37ec3a6ae61a
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex ded9dcfa81..c9cc92172c 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -283,7 +283,7 @@ jobs:node-version: ${{ matrix.node_version }}- uses: microsoft/playwright-github-action@v1- run: npm ci- - run: bash test/installation-tests/installation-tests.sh+ - run: bash packages/installation-tests/installation-tests.shheadful_linux:name: "Headful Linux"diff --git a/packages/README.md b/packages/README.mdindex b059cb8eb1..6333b66c6b 100644--- a/packages/README.md+++ b/packages/README.md@@ -39,7 +39,7 @@ $ ls ./packages/playwright # inspect the folder## Testing packages-To test packages, use [`//tests/installation-tests/installation-tests.sh`](../tests/installation-tests/installation-tests.sh).+To test packages, use [`//packages/installation-tests/installation-tests.sh`](./installation-tests/installation-tests.sh).## Publishing packagesdiff --git a/test/installation-tests/.gitignore b/packages/installation-tests/.gitignoresimilarity index 100%rename from test/installation-tests/.gitignorerename to packages/installation-tests/.gitignorediff --git a/test/installation-tests/README.md b/packages/installation-tests/README.mdsimilarity index 100%rename from test/installation-tests/README.mdrename to packages/installation-tests/README.mddiff --git a/test/installation-tests/installation-tests.sh b/packages/installation-tests/installation-tests.shsimilarity index 83%rename from test/installation-tests/installation-tests.shrename to packages/installation-tests/installation-tests.shindex 68045b1ace..4c4513d26e 100755--- a/test/installation-tests/installation-tests.sh+++ b/packages/installation-tests/installation-tests.sh@@ -26,6 +26,7 @@ SANITY_JS="$(pwd -P)/../sanity.js"TEST_ROOT="$(pwd -P)"function run_tests {+ test_typescript_typestest_skip_browser_downloadtest_playwright_global_installation_subsequent_installstest_playwright_should_work@@ -35,11 +36,32 @@ function run_tests {test_playwright_global_installation}+function test_typescript_types {+ initialize_test "${FUNCNAME[0]}"++ # install all packages.+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CORE_TGZ}+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_FIREFOX_TGZ}+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_WEBKIT_TGZ}+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CHROMIUM_TGZ}++ # typecheck all packages.+ for PKG_NAME in "playwright" \+ "playwright-core" \+ "playwright-firefox" \+ "playwright-chromium" \+ "playwright-webkit"+ do+ echo "Checking types of ${PKG_NAME}"+ echo "import { Page } from '${PKG_NAME}';" > "${PKG_NAME}.ts" && tsc "${PKG_NAME}.ts"+ done;+}+function test_playwright_global_installation {initialize_test "${FUNCNAME[0]}"local BROWSERS="$(pwd -P)/browsers"- PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_CORE_TGZ}PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}if [[ ! -d "${BROWSERS}" ]]; thenecho "Directory for shared browsers was not created!"@@ -61,7 +83,6 @@ function test_playwright_global_installation_subsequent_installs {local BROWSERS="$(pwd -P)/browsers"mkdir install-1 && pushd install-1 && npm init -y- PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_CORE_TGZ}PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}# Note: the `npm install` would not actually crash, the error# is merely logged to the console. To reproduce the error, we should make@@ -74,7 +95,6 @@ function test_playwright_global_installation_subsequent_installs {function test_skip_browser_download {initialize_test "${FUNCNAME[0]}"- npm install ${PLAYWRIGHT_CORE_TGZ}OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; thenecho "missing log message that browsers download is skipped"@@ -90,7 +110,6 @@ function test_skip_browser_download {function test_playwright_should_work {initialize_test "${FUNCNAME[0]}"- npm install ${PLAYWRIGHT_CORE_TGZ}npm install ${PLAYWRIGHT_TGZ}cp ${SANITY_JS} . && node sanity.js playwright chromium firefox webkit}@@ -98,7 +117,6 @@ function test_playwright_should_work {function test_playwright_chromium_should_work {initialize_test "${FUNCNAME[0]}"- npm install ${PLAYWRIGHT_CORE_TGZ}npm install ${PLAYWRIGHT_CHROMIUM_TGZ}cp ${SANITY_JS} . && node sanity.js playwright-chromium chromium}@@ -106,7 +124,6 @@ function test_playwright_chromium_should_work {function test_playwright_webkit_should_work {initialize_test "${FUNCNAME[0]}"- npm install ${PLAYWRIGHT_CORE_TGZ}npm install ${PLAYWRIGHT_WEBKIT_TGZ}cp ${SANITY_JS} . && node sanity.js playwright-webkit webkit}@@ -114,7 +131,6 @@ function test_playwright_webkit_should_work {function test_playwright_firefox_should_work {initialize_test "${FUNCNAME[0]}"- npm install ${PLAYWRIGHT_CORE_TGZ}npm install ${PLAYWRIGHT_FIREFOX_TGZ}cp ${SANITY_JS} . && node sanity.js playwright-firefox firefox}diff --git a/test/installation-tests/sanity.js b/packages/installation-tests/sanity.jssimilarity index 100%rename from test/installation-tests/sanity.jsrename to packages/installation-tests/sanity.jsdiff --git a/packages/playwright-chromium/index.d.ts b/packages/playwright-chromium/index.d.tsindex 872acf1212..a5d8a610be 100644--- a/packages/playwright-chromium/index.d.ts+++ b/packages/playwright-chromium/index.d.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import * as types from 'playwright-core/types/types';+import * as types from './types/types';-export * from 'playwright-core/types/types';+export * from './types/types';export const chromium: types.BrowserType<types.ChromiumBrowser>;diff --git a/packages/playwright-core/index.d.ts b/packages/playwright-core/index.d.tsnew file mode 100644index 0000000000..4e7b270a07--- /dev/null+++ b/packages/playwright-core/index.d.ts@@ -0,0 +1,22 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import * as types from './types/types';++export * from './types/types';+export const webkit: types.BrowserType<types.WebKitBrowser>;+export const chromium: types.BrowserType<types.ChromiumBrowser>;+export const firefox: types.BrowserType<types.FirefoxBrowser>;diff --git a/packages/playwright-firefox/index.d.ts b/packages/playwright-firefox/index.d.tsindex 894df7d615..dc34fe5d12 100644--- a/packages/playwright-firefox/index.d.ts+++ b/packages/playwright-firefox/index.d.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import * as types from 'playwright-core/types/types';+import * as types from './types/types';-export * from 'playwright-core/types/types';+export * from './types/types';export const firefox: types.BrowserType<types.FirefoxBrowser>;diff --git a/packages/playwright-webkit/index.d.ts b/packages/playwright-webkit/index.d.tsindex 45cbed44d9..6da7c60d11 100644--- a/packages/playwright-webkit/index.d.ts+++ b/packages/playwright-webkit/index.d.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import * as types from 'playwright-core/types/types';+import * as types from './types/types';-export * from 'playwright-core/types/types';+export * from './types/types';export const webkit: types.BrowserType<types.WebKitBrowser>;diff --git a/packages/playwright/index.d.ts b/packages/playwright/index.d.tsindex a5bc85a60f..4e7b270a07 100644--- a/packages/playwright/index.d.ts+++ b/packages/playwright/index.d.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import * as types from 'playwright-core/types/types';+import * as types from './types/types';-export * from 'playwright-core/types/types';+export * from './types/types';export const webkit: types.BrowserType<types.WebKitBrowser>;export const chromium: types.BrowserType<types.ChromiumBrowser>;export const firefox: types.BrowserType<types.FirefoxBrowser>;