From 5b2e8446491225985e20a7d1af54297c77d00f59 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 17:00:21 +0000 Subject: [PATCH] cherry-pick(#30798): test(esm): fix import attribute tests --- tests/playwright-test/esm.spec.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/playwright-test/esm.spec.ts b/tests/playwright-test/esm.spec.ts index 952cabb09b..662fe68dac 100644 --- a/tests/playwright-test/esm.spec.ts +++ b/tests/playwright-test/esm.spec.ts @@ -39,9 +39,10 @@ test('should support import assertions', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': ` import packageJSON from './package.json' assert { type: 'json' }; + console.log('imported value: ' + packageJSON.foo); export default { }; `, - 'package.json': JSON.stringify({ type: 'module' }), + 'package.json': JSON.stringify({ type: 'module', foo: 'bar' }), 'a.esm.test.ts': ` import { test, expect } from '@playwright/test'; @@ -53,23 +54,28 @@ test('should support import assertions', async ({ runInlineTest }) => { expect(result.exitCode).toBe(0); expect(result.passed).toBe(1); + expect(result.stdout).toContain('imported value: bar'); }); test('should support import attributes', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': ` import packageJSON from './package.json' with { type: 'json' }; + console.log('imported value (config): ' + packageJSON.foo); export default { }; `, - 'package.json': JSON.stringify({ type: 'module' }), + 'package.json': JSON.stringify({ type: 'module', foo: 'bar' }), 'a.test.ts': ` - import config from './config.json' with { type: 'json' }; + import config from './package.json' with { type: 'json' }; + console.log('imported value (test): ' + config.foo); import { test, expect } from '@playwright/test'; test('pass', async () => {}); ` }); expect(result.exitCode).toBe(0); expect(result.passed).toBe(1); + expect(result.stdout).toContain('imported value (config): bar'); + expect(result.stdout).toContain('imported value (test): bar'); }); test('should import esm from ts when package.json has type module in experimental mode', async ({ runInlineTest }) => {