我试图使用Jest的新特性(自)来匹配包含生成字段的对象数组。我尝试使用expect.arrayContaining和expect.objectContaining同时使用普通对象和匹配器定义,就像手动匹配时一样。目前有什么办法可以做到吗?
const sportsBallPeople = [
{
createdAt: new Date(),
name: 'That one famous guy from Cleveland'
},
{
createdAt: new Date(),
name: 'That tall guy
我有一个像这样的测试文件:(我使用的是创建-反应-应用程序)
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/Calculator';
import { getAction, getResult } from './actions/'
import {shallow} from 'enzyme';
import toJson from 'enzyme-to-json
我的Jest测试失败了,因为每次运行测试时,键中的时间戳是不同的:
FAIL ./App.test.js
✕ renders without crashing (72ms)
● renders without crashing
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot
+ Received
@@ -347,11 +347,11 @@
"index": 0,
我构建React应用程序已经有一段时间了,所以我想做一个React组件库。我一直在阅读有关方法的文章,并采用了一种方法,在这种方法中,您可以使用Webpack和Babel来绑定而不使用React,因为如果您不这样做,将会出现错误,因为将导入两个版本的React (一个在组件库中,一个在应用程序中)。无论如何,我有一个Jest安装文件,其中包含以下内容: import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
configure({ adapter: ne