我使用create-react-app创建了一个简单的App,然后安装了酶并使其成功运行,但是快照文件中的信息太多!
// the App.js hasn't been modified
// App.test.js
import React from 'react'
import { shallow } from 'enzyme'
import App from './App'
it('renders correctly', () => {
const wrapper = shallow(<App />)
expect(wrapper.render()).toMatchSnapshot()
})
我的快照文件
// Jest Snapshot v1, https://jestjs.io/docs/en/snapshot-testing
exports[`renders correctly 1`] = `
initialize {
"0": Object {
"attribs": Object {
"class": "App",
},
"children": Array [
Object {
"attribs": Object {
"class": "App-header",
},
"children": Array [
//
// more than 500 lines has been omitted there
//
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
},
},
"_root": [Circular],
"length": 1,
"options": Object {
"decodeEntities": true,
"normalizeWhitespace": false,
"withDomLvl1": true,
"xml": false,
},
}
`;
我只希望快照文件包含较少的信息,例如jest official website我该怎么办?
我希望快照文件仅包含一些简单的DOM节点的信息,而不是React组件的所有详细信息像这样
exports[`renders correctly 1`] = `
<a
className="normal"
href="http://www.facebook.com"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
Facebook
</a>
`;