add test for exports field

This commit is contained in:
Simon Knott 2024-08-09 14:42:16 +02:00
parent ca1ad4d57e
commit 9a80386c7d
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -606,6 +606,43 @@ test('should import packages with non-index main script through path resolver',
expect(result.output).toContain(`foo=42`);
});
test('does not honor `exports` field after type mapping', async ({ runInlineTest }) => {
const result = await runInlineTest({
'app/pkg/main.ts': `
export const filename = 'main.ts';
`,
'app/pkg/index.js': `
export const filename = 'index.js';
`,
'app/pkg/package.json': JSON.stringify({
exports: { '.': { require: './main.ts' } }
}),
'package.json': JSON.stringify({
name: 'example-project'
}),
'playwright.config.ts': `
export default {};
`,
'tsconfig.json': JSON.stringify({
compilerOptions: {
baseUrl: '.',
paths: {
'app/*': ['app/*'],
},
}
}),
'example.spec.ts': `
import { filename } from 'app/pkg';
import { test, expect } from '@playwright/test';
test('test', ({}) => {
console.log('filename=' + filename);
});
`,
});
expect(result.output).toContain('filename=index.js');
});
test('should respect tsconfig project references', async ({ runInlineTest }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29256' });