My Setup
I have a mono repo with jest tests in each package.
My code
Github repo here.
I have distilled my issue in an example package lambda-a
which has the following tsconfig.json
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"baseUrl": "./",
"composite": true,
"paths": {
"@example/*": ["src/example/*"]
}
},
"include": ["src/**/*"]
}
and the following jest.config.js
/* eslint-disable u/typescript-eslint/no-var-requires */
const base = require('../../jest.config.base.js');
const package = require('./package.json');
module.exports = {
...base,
name: package.name,
displayName: package.name,
roots: ['<rootDir>/src'],
moduleDirectories: ['node_modules', '<rootDir>'],
moduleNameMapper: {
'^@example/(.*)$': '<rootDir>/src/example/$1',
'^scr/(.*)$': '<rootDir>/src/$1',
},
};
My Problem
For my src *.ts
files I can use relative, absolute and alias imports as shown here
For tests I am using *.test.ts
files. My problem is that in my tests absolute and alias imports do not work as shown here
Actually the tests run fine. My only issue is the linting errors and the fact that vs code doesn't give me any intelisense for the modules imported absolutely.
How can I get absolute and alias imports to work correctly in my tests?
Thanks :)