我是 ReScript(以前的 BuckleScript)的新手,并尝试创建一个基本的项目模板。我在设置单元测试时遇到问题。这是我当前的设置:
文件夹结构
src/Demo.res
test/Demo.test.res
rescript.json
在
rescript.json
我有:
{
"sources": [
{
"dir": "src",
"subdirs": true
},
{
"dir": "test",
"subdirs": true,
"type": "dev"
}
],
// ...
}
在
Demo.test.res
我有:
open Demo
// ...
我收到错误:
The module or file Demo can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json?
- Did you include the file's directory to the "sources" in bsconfig.json?
据我了解,我不必向依赖项列表添加任何内容,因为
src
和 test
文件夹都被列为源。任何帮助将不胜感激。
事实证明,我为测试模块选择的文件名导致了问题。将测试文件从
Demo.test.res
更改为 DemoTest.res
解决了该问题,并且 open Demo
现在可以按预期工作。
我不确定为什么
Demo.test.res
导致这个问题。我猜测 Demo.test.res
被解释为另一个名为 Demo
的模块,它遮盖了另一个模块。