Skip to content

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

fix(test-runner): do not require esModuleInterop=true (#7100)

Max Schmitta3a9ccad6fd2
diff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.ts
index 233228bb8f..8b5d06124a 100644
--- a/tests/playwright-test/expect.spec.ts
+++ b/tests/playwright-test/expect.spec.ts
@@ -73,6 +73,31 @@ test('should work with default expect matchers', async ({runTSC}) => {
expect(result.exitCode).toBe(0);
});
+test('should work with default expect matchers and esModuleInterop=false', async ({runTSC}) => {
+ const result = await runTSC({
+ 'a.spec.ts': `
+ const { test } = pwt;
+ test.expect(42).toBe(42);
+ `,
+ 'tsconfig.json': JSON.stringify({
+ 'compilerOptions': {
+ 'target': 'ESNext',
+ 'moduleResolution': 'node',
+ 'module': 'commonjs',
+ 'strict': true,
+ 'rootDir': '.',
+ 'esModuleInterop': false,
+ 'allowSyntheticDefaultImports': false,
+ 'lib': ['esnext', 'dom', 'DOM.Iterable']
+ },
+ 'exclude': [
+ 'node_modules'
+ ]
+ }),
+ });
+ expect(result.exitCode).toBe(0);
+});
+
test('should work with custom PlaywrightTest namespace', async ({runTSC}) => {
const result = await runTSC({
'global.d.ts': `
diff --git a/tests/playwright-test/playwright-test-fixtures.ts b/tests/playwright-test/playwright-test-fixtures.ts
index 3e2fbd09fb..4b4b6dfc63 100644
--- a/tests/playwright-test/playwright-test-fixtures.ts
+++ b/tests/playwright-test/playwright-test-fixtures.ts
@@ -229,7 +229,7 @@ export const test = base.extend<Fixtures>({
runTSC: async ({}, use, testInfo) => {
let tscResult: TSCResult | undefined;
await use(async files => {
- const baseDir = await writeFiles(testInfo, { ...files, 'tsconfig.json': JSON.stringify(TSCONFIG) });
+ const baseDir = await writeFiles(testInfo, { 'tsconfig.json': JSON.stringify(TSCONFIG), ...files });
tscResult = await runTSC(baseDir);
return tscResult;
});
diff --git a/types/testExpect.d.ts b/types/testExpect.d.ts
index ab1935c1ac..1dd6afe7d1 100644
--- a/types/testExpect.d.ts
+++ b/types/testExpect.d.ts
@@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
-import type expect from 'expect';
+import type * as expect from 'expect';
import type { ExpectedAssertionsErrors } from 'expect/build/types';
export declare type AsymmetricMatcher = Record<string, any>;