chore: support esm imports (#3125)
This commit is contained in:
parent
21581a4e8b
commit
d234dac752
|
@ -46,7 +46,7 @@ jobs:
|
|||
if: ${{ always() }}
|
||||
with:
|
||||
name: ${{ matrix.browser }}-linux-jest-report
|
||||
path: jest-report.json
|
||||
path: jest-report.json
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
|
@ -82,7 +82,7 @@ jobs:
|
|||
if: ${{ always() }}
|
||||
with:
|
||||
name: ${{ matrix.browser }}-mac-jest-report
|
||||
path: jest-report.json
|
||||
path: jest-report.json
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
|
@ -134,6 +134,7 @@ jobs:
|
|||
test-package-installations:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node_version:
|
||||
- "^10.17.0" # pre 10.17, --unhandled-rejections=strict was not an option (https://github.com/nodejs/node/pull/26599) which we need in our tests
|
||||
|
|
|
@ -14,6 +14,7 @@ lib/injected/
|
|||
!index.d.ts
|
||||
|
||||
!index.js
|
||||
!index.mjs
|
||||
!install.js
|
||||
!README.md
|
||||
!LICENSE
|
||||
|
|
|
@ -83,7 +83,7 @@ if (args.some(arg => arg === '--help')) {
|
|||
|
||||
// 2. Setup cleanup if needed
|
||||
if (!args.some(arg => arg === '--no-cleanup')) {
|
||||
process.on('exit', () => {
|
||||
process.on('exit', () => {
|
||||
cleanupPaths.forEach(cleanupPath => rmSync(cleanupPath, {}));
|
||||
});
|
||||
process.on('SIGINT', () => process.exit(2));
|
||||
|
@ -123,6 +123,10 @@ if (!package) {
|
|||
engines: pwInternalJSON.engines,
|
||||
homepage: pwInternalJSON.homepage,
|
||||
main: 'index.js',
|
||||
exports: {
|
||||
import: './index.mjs',
|
||||
require: './index.js',
|
||||
},
|
||||
scripts: {
|
||||
install: 'node install.js',
|
||||
},
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* 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 { chromium, selectors, devices, errors } from 'playwright-chromium';
|
||||
import playwright from 'playwright-chromium';
|
||||
|
||||
if (playwright.chromium !== chromium)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [chromium]) {
|
||||
const browser = await browserType.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.evaluate(() => navigator.userAgent);
|
||||
await browser.close();
|
||||
}
|
||||
console.log(`esm SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* 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 { firefox, selectors, devices, errors } from 'playwright-firefox';
|
||||
import playwright from 'playwright-firefox';
|
||||
|
||||
if (playwright.firefox !== firefox)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [firefox]) {
|
||||
const browser = await browserType.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.evaluate(() => navigator.userAgent);
|
||||
await browser.close();
|
||||
}
|
||||
console.log(`esm SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* 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 { webkit, selectors, devices, errors } from 'playwright-webkit';
|
||||
import playwright from 'playwright-webkit';
|
||||
|
||||
if (playwright.webkit !== webkit)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [webkit]) {
|
||||
const browser = await browserType.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.evaluate(() => navigator.userAgent);
|
||||
await browser.close();
|
||||
}
|
||||
console.log(`esm SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* 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 { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
|
||||
import playwright from 'playwright';
|
||||
|
||||
if (playwright.chromium !== chromium)
|
||||
process.exit(1);
|
||||
if (playwright.firefox !== firefox)
|
||||
process.exit(1);
|
||||
if (playwright.webkit !== webkit)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [chromium, firefox, webkit]) {
|
||||
const browser = await browserType.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.evaluate(() => navigator.userAgent);
|
||||
await browser.close();
|
||||
}
|
||||
console.log(`esm SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -22,8 +22,17 @@ PLAYWRIGHT_CHROMIUM_TGZ="$(node ${PACKAGE_BUILDER} playwright-chromium ./playwri
|
|||
PLAYWRIGHT_WEBKIT_TGZ="$(node ${PACKAGE_BUILDER} playwright-webkit ./playwright-webkit.tgz)"
|
||||
PLAYWRIGHT_FIREFOX_TGZ="$(node ${PACKAGE_BUILDER} playwright-firefox ./playwright-firefox.tgz)"
|
||||
|
||||
SANITY_JS="$(pwd -P)/../sanity.js"
|
||||
SCRIPTS_PATH="$(pwd -P)/.."
|
||||
TEST_ROOT="$(pwd -P)"
|
||||
NODE_VERSION="$(node --version)"
|
||||
|
||||
function copy_test_scripts {
|
||||
cp "${SCRIPTS_PATH}/sanity.js" .
|
||||
cp "${SCRIPTS_PATH}/esm-playwright.mjs" .
|
||||
cp "${SCRIPTS_PATH}/esm-playwright-chromium.mjs" .
|
||||
cp "${SCRIPTS_PATH}/esm-playwright-firefox.mjs" .
|
||||
cp "${SCRIPTS_PATH}/esm-playwright-webkit.mjs" .
|
||||
}
|
||||
|
||||
function run_tests {
|
||||
test_typescript_types
|
||||
|
@ -67,7 +76,7 @@ function test_playwright_global_installation {
|
|||
echo "Directory for shared browsers was not created!"
|
||||
exit 1
|
||||
fi
|
||||
cp ${SANITY_JS} .
|
||||
copy_test_scripts
|
||||
if node sanity.js playwright chromium 2>/dev/null; then
|
||||
echo "Should not be able to launch chromium without PLAYWRIGHT_BROWSERS_PATH variable!"
|
||||
exit 1
|
||||
|
@ -111,28 +120,44 @@ function test_playwright_should_work {
|
|||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_TGZ}
|
||||
cp ${SANITY_JS} . && node sanity.js playwright chromium firefox webkit
|
||||
copy_test_scripts
|
||||
node sanity.js playwright chromium firefox webkit
|
||||
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
|
||||
node esm-playwright.mjs
|
||||
fi
|
||||
}
|
||||
|
||||
function test_playwright_chromium_should_work {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_CHROMIUM_TGZ}
|
||||
cp ${SANITY_JS} . && node sanity.js playwright-chromium chromium
|
||||
copy_test_scripts
|
||||
node sanity.js playwright-chromium chromium
|
||||
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
|
||||
node esm-playwright-chromium.mjs
|
||||
fi
|
||||
}
|
||||
|
||||
function test_playwright_webkit_should_work {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_WEBKIT_TGZ}
|
||||
cp ${SANITY_JS} . && node sanity.js playwright-webkit webkit
|
||||
copy_test_scripts
|
||||
node sanity.js playwright-webkit webkit
|
||||
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
|
||||
node esm-playwright-webkit.mjs
|
||||
fi
|
||||
}
|
||||
|
||||
function test_playwright_firefox_should_work {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_FIREFOX_TGZ}
|
||||
cp ${SANITY_JS} . && node sanity.js playwright-firefox firefox
|
||||
copy_test_scripts
|
||||
node sanity.js playwright-firefox firefox
|
||||
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
|
||||
node esm-playwright-firefox.mjs
|
||||
fi
|
||||
}
|
||||
|
||||
function initialize_test {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const requireName = process.argv[2];
|
||||
const browsers = process.argv.slice(3);
|
||||
|
||||
|
@ -11,6 +27,7 @@ const playwright = require(requireName);
|
|||
await page.evaluate(() => navigator.userAgent);
|
||||
await browser.close();
|
||||
}
|
||||
console.log(`require SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const chromium = playwright.chromium;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const chromium = playwright.chromium;
|
||||
export const firefox = playwright.firefox;
|
||||
export const webkit = playwright.webkit;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const electron = playwright.electron;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const firefox = playwright.firefox;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const webkit = playwright.webkit;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const chromium = playwright.chromium;
|
||||
export const firefox = playwright.firefox;
|
||||
export const webkit = playwright.webkit;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
Loading…
Reference in New Issue