Skip to content

Commit

Permalink
add test for exports field
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Aug 9, 2024
1 parent ca1ad4d commit 9a80386
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/playwright-test/resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down

0 comments on commit 9a80386

Please sign in to comment.