跳到主要内容

Reason Testing Library

几个 testing-library 的绑定已经被移植到 ReasonML

bs-react-testing-library 包含 React Testing LibraryBuckleScript 绑定。

bs-dom-testing-library 包含 DOM Testing Library[BuckleScript] 绑定。

npm install --save-dev bs-dom-testing-library
npm install --save-dev bs-react-testing-library

设置

安装后,你需要让你的包 bsconfig.json 文件如下配置:

{
"bs-dev-dependencies": ["bs-react-testing-library"]
}

or

{
"bs-dev-dependencies": ["bs-dom-testing-library"]
}

其它依赖

bs-platform

这就是 BuckleScript 用来将 Reason 代码编译成 JS 的工具。如果你的项目 中没有它,你可以像这样安装它:

npm install --save-dev bs-platform

bs-jest

这是推荐的测试运行器,是一个围绕 Jest 的封装器。这里所有的例子都将使用它。

npm install --save-dev @glennsl/bs-jest

然后,更新 bsconfig.json:

{
"bs-dev-dependencies": ["@glennsl/bs-jest"]
}