mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
fix(ct): allow importing json files (#30067)
While we are not fully resolving imports during compilation, do not treat `json` as a non-importable asset. Fixes #29926.
This commit is contained in:
parent
1539cde034
commit
7a3c002944
@ -193,7 +193,4 @@ const artifactExtensions = new Set([
|
||||
'.ttf',
|
||||
'.otf',
|
||||
'.eot',
|
||||
|
||||
// Other assets
|
||||
'.json',
|
||||
]);
|
||||
]);
|
||||
|
@ -497,6 +497,24 @@ test('should render component via re-export', async ({ runInlineTest }, testInfo
|
||||
expect(result.passed).toBe(1);
|
||||
});
|
||||
|
||||
test('should import json', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': playwrightCtConfigText,
|
||||
'playwright/index.html': `<script type="module" src="./index.ts"></script>`,
|
||||
'playwright/index.ts': ``,
|
||||
'src/some.json': `{ "some": "value" }`,
|
||||
'src/button.test.tsx': `
|
||||
import { test, expect } from '@playwright/experimental-ct-react';
|
||||
import json from './some.json';
|
||||
test('pass', async ({}) => {
|
||||
expect(json.some).toBe('value');
|
||||
});
|
||||
`,
|
||||
}, { workers: 1 });
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
});
|
||||
|
||||
test('should render component exported via fixture', async ({ runInlineTest }, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': playwrightCtConfigText,
|
||||
|
Loading…
Reference in New Issue
Block a user