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:
Andrey Lushnikov 2020-05-26 17:19:05 -07:00 committed by GitHub
parent 415b11487d
commit 37ec3a6ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 17 deletions

View File

@ -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"

View File

@ -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

View File

@ -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
}

View File

@ -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
View 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>;

View File

@ -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>;

View File

@ -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>;

View File

@ -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>;