review feedback
This commit is contained in:
parent
c83ba0c8d4
commit
0dccf16658
|
|
@ -151,29 +151,31 @@ test('should not transform external', async ({ runInlineTest }) => {
|
||||||
expect(result.output).toMatch(/(Cannot use import statement outside a module|require\(\) of ES Module .* not supported.)/);
|
expect(result.output).toMatch(/(Cannot use import statement outside a module|require\(\) of ES Module .* not supported.)/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should support import assertions', {
|
for (const type of ['module', undefined]) {
|
||||||
annotation: {
|
test(`should support import assertions with type=${type} in the package.json`, {
|
||||||
type: 'issue',
|
annotation: {
|
||||||
description: 'https://github.com/microsoft/playwright/issues/32659'
|
type: 'issue',
|
||||||
}
|
description: 'https://github.com/microsoft/playwright/issues/32659'
|
||||||
}, async ({ runInlineTest }) => {
|
}
|
||||||
const result = await runInlineTest({
|
}, async ({ runInlineTest }) => {
|
||||||
'playwright.config.ts': `
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
import packageJSON from './package.json' assert { type: 'json' };
|
import packageJSON from './package.json' assert { type: 'json' };
|
||||||
console.log('imported value: ' + packageJSON.foo);
|
console.log('imported value: ' + packageJSON.foo);
|
||||||
export default { };
|
export default { };
|
||||||
`,
|
`,
|
||||||
'package.json': JSON.stringify({ foo: 'bar' }),
|
'package.json': JSON.stringify({ foo: 'bar', type }),
|
||||||
'a.esm.test.ts': `
|
'a.test.ts': `
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
test('check project name', ({}, testInfo) => {
|
test('check project name', ({}, testInfo) => {
|
||||||
expect(1).toBe(1);
|
expect(1).toBe(1);
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
expect(result.stdout).toContain('imported value: bar');
|
expect(result.stdout).toContain('imported value: bar');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,28 +35,6 @@ test('should load nested as esm when package.json has type module', async ({ run
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
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', foo: 'bar' }),
|
|
||||||
'a.esm.test.ts': `
|
|
||||||
import { test, expect } from '@playwright/test';
|
|
||||||
|
|
||||||
test('check project name', ({}, testInfo) => {
|
|
||||||
expect(1).toBe(1);
|
|
||||||
});
|
|
||||||
`
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.exitCode).toBe(0);
|
|
||||||
expect(result.passed).toBe(1);
|
|
||||||
expect(result.stdout).toContain('imported value: bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should support import attributes', async ({ runInlineTest }) => {
|
test('should support import attributes', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue