diff --git a/e2e/__external-repos__/simple-project-references/jest.config.js b/e2e/__external-repos__/simple-project-references/jest.config.js index 1942d9a712..18ff5f36d5 100644 --- a/e2e/__external-repos__/simple-project-references/jest.config.js +++ b/e2e/__external-repos__/simple-project-references/jest.config.js @@ -1,12 +1,16 @@ /** @type {import('@jest/types').Config.InitialOptions} */ /** @typedef {import('ts-jest')} */ +const { pathsToModuleNameMapper } = require('ts-jest/utils'); +const { compilerOptions } = require('./tsconfig-base'); + module.exports = { preset: 'ts-jest', testEnvironment: 'node', // Ignore the TS project `outDir` // https://github.com/kulshekhar/ts-jest/issues/765 testPathIgnorePatterns: ['/target/'], + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }), globals: { 'ts-jest': { isolatedModules: true, diff --git a/e2e/__external-repos__/simple-project-references/src/__tests__/divide.ts b/e2e/__external-repos__/simple-project-references/src/__tests__/divide.ts new file mode 100644 index 0000000000..a83fa96f0f --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/__tests__/divide.ts @@ -0,0 +1,10 @@ +import { divide } from '~' +import { divide as _divide } from '~/divide' + +test('imports same divide function', () => { + expect(_divide).toBe(divide) +}) + +test('divides 3 / 2 to equal 1.5', () => { + expect(divide(3, 2)).toBe(1.5) +}) diff --git a/e2e/__external-repos__/simple-project-references/src/__tests__/multiply.ts b/e2e/__external-repos__/simple-project-references/src/__tests__/multiply.ts new file mode 100644 index 0000000000..2162500b7c --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/__tests__/multiply.ts @@ -0,0 +1,5 @@ +import { multiply } from '@/multiply' + +test('multiplies 2 * 2 to equal 4', () => { + expect(multiply(2, 2)).toBe(4) +}) diff --git a/e2e/__external-repos__/simple-project-references/src/__tests__/subtract.ts b/e2e/__external-repos__/simple-project-references/src/__tests__/subtract.ts new file mode 100644 index 0000000000..9455bd3067 --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/__tests__/subtract.ts @@ -0,0 +1,5 @@ +import { subtract } from '@/subtract' + +test('subtracts 3 - 1 to equal 2', () => { + expect(subtract(3, 1)).toBe(2) +}) diff --git a/e2e/__external-repos__/simple-project-references/src/math/divide.ts b/e2e/__external-repos__/simple-project-references/src/math/divide.ts new file mode 100644 index 0000000000..7e72575935 --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/math/divide.ts @@ -0,0 +1,3 @@ +import divide from 'lodash/divide' + +export { divide } diff --git a/e2e/__external-repos__/simple-project-references/src/nested/src/multiply.ts b/e2e/__external-repos__/simple-project-references/src/nested/src/multiply.ts new file mode 100644 index 0000000000..eabf98d6ab --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/nested/src/multiply.ts @@ -0,0 +1,3 @@ +import multiply from 'lodash/multiply' + +export { multiply } diff --git a/e2e/__external-repos__/simple-project-references/src/nested/subtract.ts b/e2e/__external-repos__/simple-project-references/src/nested/subtract.ts new file mode 100644 index 0000000000..f329a6fb22 --- /dev/null +++ b/e2e/__external-repos__/simple-project-references/src/nested/subtract.ts @@ -0,0 +1,3 @@ +import subtract from 'lodash/subtract' + +export { subtract } diff --git a/e2e/__external-repos__/simple-project-references/tsconfig-base.json b/e2e/__external-repos__/simple-project-references/tsconfig-base.json index 1a5cd690cb..5d975f771b 100644 --- a/e2e/__external-repos__/simple-project-references/tsconfig-base.json +++ b/e2e/__external-repos__/simple-project-references/tsconfig-base.json @@ -11,6 +11,19 @@ "rootDir": "./src/", "types": [], "allowSyntheticDefaultImports": true, - "esModuleInterop": true + "esModuleInterop": true, + "baseUrl": ".", + "paths": { + "@/*": [ + "src/nested/*", + "src/nested/src/*" + ], + "~": [ + "src/math/divide.ts" + ], + "~/*": [ + "src/math/*" + ] + } } }