ReScript 测试设置:无法打开 src 模块

问题描述 投票:0回答:1

我是 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
文件夹都被列为源。任何帮助将不胜感激。

unit-testing rescript
1个回答
0
投票

事实证明,我为测试模块选择的文件名导致了问题。将测试文件从

Demo.test.res
更改为
DemoTest.res
解决了该问题,并且
open Demo
现在可以按预期工作。

我不确定为什么

Demo.test.res
导致这个问题。我猜测
Demo.test.res
被解释为另一个名为
Demo
的模块,它遮盖了另一个模块。

© www.soinside.com 2019 - 2024. All rights reserved.