Javascript 使用gatsby插件根导入解析单元测试的路径
运行我的应用程序时,一切正常。但是,如果我使用jest运行测试,该测试将无法连接gatsby配置文件中的路径。下面是我遇到的一个等级制度 盖茨比配置:Javascript 使用gatsby插件根导入解析单元测试的路径,javascript,path,gatsby,Javascript,Path,Gatsby,运行我的应用程序时,一切正常。但是,如果我使用jest运行测试,该测试将无法连接gatsby配置文件中的路径。下面是我遇到的一个等级制度 盖茨比配置: ... { resolve: "gatsby-plugin-root-import", options: { reducers: path.join(__dirname, "src/reducers"), sagas: path.join(__dir
...
{
resolve: "gatsby-plugin-root-import",
options: {
reducers: path.join(__dirname, "src/reducers"),
sagas: path.join(__dirname, "src/sagas"),
web: path.join(__dirname, "src/web"),
test: path.join(__dirname, "src/web"), <-------- test cases don't live on the root
},
},
....
● Test suite failed to run
Cannot find module 'web/components/graphs/line-graph' from 'src/web/components/card/index.js'
Require stack:
src/web/components/card/index.js
src/web/components/card/test/index.test.js
1 | import React from "react"
2 | import { string, array } from "prop-types"
> 3 | import LineGraph from "web/components/graphs/line-graph"