Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(playwright-test): have the proper default export (#7328)

Joel Einbinder7caf05b24a58
diff --git a/packages/installation-tests/esm-playwright-test.mjs b/packages/installation-tests/esm-playwright-test.mjs
index 0384c70341..c824e203b4 100644
--- a/packages/installation-tests/esm-playwright-test.mjs
+++ b/packages/installation-tests/esm-playwright-test.mjs
@@ -14,9 +14,11 @@
* limitations under the License.
*/
-import { chromium, firefox, webkit, selectors, devices, errors } from '@playwright/test';
-import playwright from '@playwright/test';
+import { chromium, firefox, webkit, selectors, devices, errors, test } from '@playwright/test';
+import * as playwright from '@playwright/test';
+import defaultExport from '@playwright/test';
import errorsFile from '@playwright/test/lib/utils/errors.js';
-
import testESM from './esm.mjs';
+if (defaultExport !== test)
+ process.exit(1);
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [chromium, firefox, webkit]);
diff --git a/packages/playwright-test/index.d.ts b/packages/playwright-test/index.d.ts
index c4573c9189..12e0a59518 100644
--- a/packages/playwright-test/index.d.ts
+++ b/packages/playwright-test/index.d.ts
@@ -16,3 +16,4 @@
export * from './types/types';
export * from './types/test';
+export { default } from './types/test';
diff --git a/packages/playwright-test/index.js b/packages/playwright-test/index.js
index cd046e0994..58d1d3a765 100644
--- a/packages/playwright-test/index.js
+++ b/packages/playwright-test/index.js
@@ -13,8 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-module.exports = {
- ...require('./lib/inprocess'),
- ...require('./lib/test/index')
+const pwt = require('./lib/test/index');
+const playwright = require('./lib/inprocess');
+const combinedExports = {
+ ...playwright,
+ ...pwt,
};
+
+Object.defineProperty(combinedExports, '__esModule', { value: true });
+
+module.exports = combinedExports;
diff --git a/packages/playwright-test/index.mjs b/packages/playwright-test/index.mjs
index c54a917122..35e5ed3168 100644
--- a/packages/playwright-test/index.mjs
+++ b/packages/playwright-test/index.mjs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import playwright from './index.js';
+import * as playwright from './index.js';
export const chromium = playwright.chromium;
export const firefox = playwright.firefox;
@@ -25,4 +25,4 @@ export const errors = playwright.errors;
export const _electron = playwright._electron;
export const _android = playwright._android;
export const test = playwright.test;
-export default playwright;
+export default playwright.default;