mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
fix(types): properly export typescript types from packages (#2364)
Drive-by: move package tests from `//test/installation-tests` to `//packages/installation-tests` Fix #2349
This commit is contained in:
parent
415b11487d
commit
37ec3a6ae6
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -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.sh
|
||||
|
||||
headful_linux:
|
||||
name: "Headful Linux"
|
||||
|
@ -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 packages
|
||||
|
@ -26,6 +26,7 @@ SANITY_JS="$(pwd -P)/../sanity.js"
|
||||
TEST_ROOT="$(pwd -P)"
|
||||
|
||||
function run_tests {
|
||||
test_typescript_types
|
||||
test_skip_browser_download
|
||||
test_playwright_global_installation_subsequent_installs
|
||||
test_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}" ]]; then
|
||||
echo "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"* ]]; then
|
||||
echo "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
|
||||
}
|
4
packages/playwright-chromium/index.d.ts
vendored
4
packages/playwright-chromium/index.d.ts
vendored
@ -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>;
|
||||
|
22
packages/playwright-core/index.d.ts
vendored
Normal file
22
packages/playwright-core/index.d.ts
vendored
Normal file
@ -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>;
|
4
packages/playwright-firefox/index.d.ts
vendored
4
packages/playwright-firefox/index.d.ts
vendored
@ -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>;
|
||||
|
4
packages/playwright-webkit/index.d.ts
vendored
4
packages/playwright-webkit/index.d.ts
vendored
@ -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>;
|
||||
|
4
packages/playwright/index.d.ts
vendored
4
packages/playwright/index.d.ts
vendored
@ -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>;
|
||||
|
Loading…
Reference in New Issue
Block a user