I am using a monorepo, where my modules are stored mostly one level above the project.
In jest.config.ts
, I am defining setupFiles as:
{
setupFiles: ["<rootDir>/../node_modules/@core/src/setupJest.ts"]
}
I would like to use an absolute path since the library directories could change
{
setupFiles: ["@core/src/setupJest.ts"]
}
I tried using roots
, moduleDirectories
, modulePaths
to define additional path, but it did not work (this is suggested by a lot of replies to similar questions on S/O, no worked for me).
Does anyone have an idea what else I can do. A bit lost, so will try anything.
Thank you
1条答案
按热度按时间kkbh8khc1#
如果有人感兴趣的话
我通过以下方法解决了这个问题:
1.将
sec/setupJest.ts
定义为@core
库的package.json
中的“导出”(setupJest
)。1.使用中
解析文件路径。4.在
setupFiles
中使用setupJestFile
变量