在 monorepo 中配置 jest

我正在尝试为 monorepo 配置 jest 结构如下:

在 monorepo 中配置 jest

这个想法是从 root 开始跨应用程序运行测试,而不是在未来可能出现的每个应用程序中安装和配置,例如 cra、gatsby、next-app 等,

jest 的配置如下:

module.exports = {
  projects: ['./others/local-jest.config.js'],moduleNameMapper: {
    '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
      '<rootDir>/__mocks__/fileMock.js','.+\\.(css|scss)$': 'identity-obj-proxy'
  },moduleDirectories: ['node_modules']
};

jest.config.js 文件位于 cra 时,一切都很顺利,identity-obj-proxy 工作正常。但是当我将它移动到安装了所有依赖项的根目录时,jest 在导入 css 文件时抛出错误

在 monorepo 中配置 jest

我一直在争取领先,但到目前为止还没有!

jinjuanyang 回答:在 monorepo 中配置 jest

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/50005.html

大家都在问