From 6e1ee47673cfe1abab28b99fa8c3e7bd71df850d Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sun, 5 May 2024 17:48:50 +0000 Subject: [PATCH] added test demonstrating include path normalization (for #73) --- .../parse-tsconfig/extends/merges.spec.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/specs/parse-tsconfig/extends/merges.spec.ts b/tests/specs/parse-tsconfig/extends/merges.spec.ts index 9e69ace..6c2e1af 100644 --- a/tests/specs/parse-tsconfig/extends/merges.spec.ts +++ b/tests/specs/parse-tsconfig/extends/merges.spec.ts @@ -192,6 +192,35 @@ export default testSuite(({ describe }) => { expect(tsconfig).toStrictEqual(expectedTsconfig); }); + test('inherits with relative path from subdirectory', async () => { + await using fixture = await createFixture({ + configs: { + 'tsconfig.base.json': createTsconfigJson({ + include: ['../src-a/*'], + }), + }, + 'src-a': { + 'a.ts': '', + 'b.ts': '', + 'c.ts': '', + }, + 'tsconfig.json': createTsconfigJson({ + extends: './configs/tsconfig.base.json', + }), + }); + + const expectedTsconfig = await getTscTsconfig(fixture.path); + delete expectedTsconfig.files; + + const tsconfig = parseTsconfig(path.join(fixture.path, 'tsconfig.json')); + + expect({ + ...tsconfig, + // See https://github.com/privatenumber/get-tsconfig/issues/73 + include: tsconfig.include?.map(includePath => `configs/../${includePath}`), + }).toStrictEqual(expectedTsconfig); + }); + test('gets overwritten', async () => { await using fixture = await createFixture({ 'src-a': {