问题描述
我正在尝试将 jest-dom 库添加到每个测试文件中。 我安装了那个包并制作了“jestSetup.js”文件并添加了 package.json 如下。
"jest":{
setupFilesAfterEnv:["<rootDir>/jestSetup.js"]
}
和 jestSetup.js 是
import @testing-library/jest-dom;
console.log("jest-dom")
测试文件是
import { render } from "@testing-library/svelte";
...
console.log("test")
expect(getByText("success notification")).toHaveClass("success");
...
但它说 toHaveClass is not defined
错误
console.log 的结果是 "jest-dom,jest"
我再次使用 jest.config.js 对其进行了测试,但结果是一样的。
我不确定为什么会这样。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)