From 92aacb934581a86d623bdc26aa148a0691f80d00 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Wed, 10 Aug 2022 02:05:48 +0300 Subject: [PATCH] test: another test for baseUrl/relative imports (#16338) #15891 --- tests/playwright-test/resolver.spec.ts | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/playwright-test/resolver.spec.ts b/tests/playwright-test/resolver.spec.ts index 3754b479ce..0c5443bad5 100644 --- a/tests/playwright-test/resolver.spec.ts +++ b/tests/playwright-test/resolver.spec.ts @@ -296,3 +296,33 @@ test('should not use baseurl for relative imports', async ({ runInlineTest }) => expect(result.passed).toBe(1); expect(result.output).not.toContain(`Could not`); }); + +test('should not use baseurl for relative imports when dir with same name exists', async ({ runInlineTest }) => { + test.fail(); + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/15891' }); + const result = await runInlineTest({ + 'frontend/tsconfig.json': `{ + "compilerOptions": { + "baseUrl": "src", + }, + }`, + 'frontend/src/utils/foo.js': ` + export const foo = -1; + `, + 'frontend/playwright/tests/utils.ts': ` + export const foo = 42; + `, + 'frontend/playwright/tests/forms_cms_standard.spec.ts': ` + // This relative import should not use baseUrl + import { foo } from './utils'; + const { test } = pwt; + test('test', ({}, testInfo) => { + expect(foo).toBe(42); + }); + `, + }); + + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); + expect(result.output).not.toContain(`Could not`); +});