Jest learning manual
最后更新于
最后更新于
异步 await expect(fetchData()).rejects
does not work
Cannot spy the fetch property because it is not a function;
No tests found, exiting with code 1
The test file need to be xxx.test.js, not xxx.js when the Jest config contains testRegex ".test.js"
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
https://www.cnblogs.com/xueyoucd/p/10495922.html 解决jest处理es模块 - 学友2000 - 博客园
安装依赖包,特别是 babel-plugin-transform-es2015-modules-commonjs
配置 babel.config.js
配置 jest.config.js
或在 package.json
中添加 jest
配置