fix(test runner): remove unused type imports during transform (#18157)
Fixes #18117.
This commit is contained in:
parent
909eda2432
commit
9fe72a1da8
|
|
@ -65,7 +65,7 @@ export function babelTransform(filename: string, isTypeScript: boolean, isModule
|
|||
setPublicClassFields: true,
|
||||
},
|
||||
presets: [
|
||||
[require('@babel/preset-typescript'), { onlyRemoveTypeImports: true }],
|
||||
[require('@babel/preset-typescript'), { onlyRemoveTypeImports: false }],
|
||||
],
|
||||
plugins,
|
||||
sourceMaps: 'both',
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ test('beforeAll from a helper file should throw', async ({ runInlineTest }) => {
|
|||
`,
|
||||
'playwright.config.ts': `
|
||||
import { test } from './my-test';
|
||||
test.extend({});
|
||||
`,
|
||||
'a.test.ts': `
|
||||
import { test } from './my-test';
|
||||
|
|
|
|||
|
|
@ -471,3 +471,20 @@ test('should load a jsx/tsx files', async ({ runInlineTest }) => {
|
|||
expect(passed).toBe(2);
|
||||
expect(exitCode).toBe(0);
|
||||
});
|
||||
|
||||
test('should remove type imports from ts', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
import { Point } from 'helper';
|
||||
const p: Point = {};
|
||||
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'node_modules/helper/index.d.ts': `
|
||||
export type Point = {};
|
||||
`,
|
||||
});
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue