我收到一个错误:Invalid Chai property: toMatchSnapshot
当我尝试使用 Jest + Enzyme 的快照测试时。我已将我的 React 版本更新为 16.2,并且将enzyme-to-json
库与 Enzyme 3 一起使用。
代码如下:
import React from 'react';
import ReactDOM from 'react-dom';
import ConnectedApp, { App } from './App';
import { ConnectedRouter } from 'react-router-redux';
import { Provider } from 'react-redux';
import { expect } from 'chai';
import { mount, shallow } from 'enzyme';
import createHistory from 'history/createMemoryHistory'
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import toJson from 'enzyme-to-json';
describe('App tests', () => { …
Run Code Online (Sandbox Code Playgroud)