mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 20:03:03 +03:00
fix(require): allow requiring internals (#3153)
This commit is contained in:
parent
3162c06f49
commit
6a4195fd1d
@ -124,8 +124,15 @@ if (!package) {
|
||||
homepage: pwInternalJSON.homepage,
|
||||
main: 'index.js',
|
||||
exports: {
|
||||
import: './index.mjs',
|
||||
require: './index.js',
|
||||
// Root import: we have a wrapper ES Module to support the following syntax.
|
||||
// const { chromium } = require('playwright');
|
||||
// import { chromium } from 'playwright';
|
||||
'.': {
|
||||
import: './index.mjs',
|
||||
require: './index.js',
|
||||
},
|
||||
// Anything else can be required/imported by providing a relative path.
|
||||
'./': './',
|
||||
},
|
||||
scripts: {
|
||||
install: 'node install.js',
|
||||
|
@ -16,10 +16,16 @@
|
||||
|
||||
import { chromium, selectors, devices, errors } from 'playwright-chromium';
|
||||
import playwright from 'playwright-chromium';
|
||||
import errorsFile from 'playwright-chromium/lib/errors.js';
|
||||
|
||||
if (playwright.chromium !== chromium)
|
||||
process.exit(1);
|
||||
|
||||
if (playwright.errors !== errors)
|
||||
process.exit(1);
|
||||
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [chromium]) {
|
||||
const browser = await browserType.launch();
|
||||
|
@ -16,10 +16,16 @@
|
||||
|
||||
import { firefox, selectors, devices, errors } from 'playwright-firefox';
|
||||
import playwright from 'playwright-firefox';
|
||||
import errorsFile from 'playwright-firefox/lib/errors.js';
|
||||
|
||||
if (playwright.firefox !== firefox)
|
||||
process.exit(1);
|
||||
|
||||
if (playwright.errors !== errors)
|
||||
process.exit(1);
|
||||
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [firefox]) {
|
||||
const browser = await browserType.launch();
|
||||
|
@ -16,10 +16,16 @@
|
||||
|
||||
import { webkit, selectors, devices, errors } from 'playwright-webkit';
|
||||
import playwright from 'playwright-webkit';
|
||||
import errorsFile from 'playwright-webkit/lib/errors.js';
|
||||
|
||||
if (playwright.webkit !== webkit)
|
||||
process.exit(1);
|
||||
|
||||
if (playwright.errors !== errors)
|
||||
process.exit(1);
|
||||
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [webkit]) {
|
||||
const browser = await browserType.launch();
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
|
||||
import playwright from 'playwright';
|
||||
import errorsFile from 'playwright/lib/errors.js';
|
||||
|
||||
if (playwright.chromium !== chromium)
|
||||
process.exit(1);
|
||||
@ -24,6 +25,11 @@ if (playwright.firefox !== firefox)
|
||||
if (playwright.webkit !== webkit)
|
||||
process.exit(1);
|
||||
|
||||
if (playwright.errors !== errors)
|
||||
process.exit(1);
|
||||
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||
process.exit(1);
|
||||
|
||||
(async () => {
|
||||
for (const browserType of [chromium, firefox, webkit]) {
|
||||
const browser = await browserType.launch();
|
||||
|
@ -19,6 +19,10 @@ const browsers = process.argv.slice(3);
|
||||
|
||||
const playwright = require(requireName);
|
||||
|
||||
// Requiring internals should work.
|
||||
const errors = require(requireName + '/lib/errors');
|
||||
const installer = require(requireName + '/lib/install/installer');
|
||||
|
||||
(async () => {
|
||||
for (const browserType of browsers) {
|
||||
const browser = await playwright[browserType].launch();
|
||||
|
Loading…
Reference in New Issue
Block a user