【文件属性】:
文件名称:jest-json:玩笑匹配器可使用JSON字符串
文件大小:5KB
文件格式:ZIP
更新时间:2021-05-07 22:17:27
javascript json jest jest-matchers JavaScript
jest-json
玩笑匹配器以使用JSON字符串。
设置
将jest-json添加到您的Jest配置中:
{
" setupTestFrameworkScriptFile " : " jest-json "
}
或者,如果您已经在使用另一个测试框架,请创建一个安装文件并要求每个文件:
require ( "jest-json" ) ;
// require("some-jest-library);
动机
假设您需要向断言foo被称为与foo("url", "{'foo': 'bar', 'spam': 'eggs'}")
// option 1
expect ( foo ) . toHaveBeenCalledWith (
"url" ,
JSON . stringify ( {
foo : "bar" ,
spam : "eggs"
} )
)
【文件预览】:
jest-json-master
----.eslintrc.yml(197B)
----test.js(2KB)
----.travis.yml(102B)
----README.md(2KB)
----index.d.ts(173B)
----__snapshots__()
--------test.js.snap(1KB)
----.gitignore(31B)
----index.js(3KB)
----package.json(818B)