Snapshot Summary › 1 snapshot written in 1 test suite.
Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 1 added, 1 total Time: 0.468s, estimated 2s Ran all test suites related to changed files.
在第一次测试运行时,组件输出的快照将保存到“__snapshots__”文件夹中:
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UsersList renders a snapshot properly 1`] = ` <div> <h4 className="box title is-4" > michael </h4> <h4 className="box title is-4" > michaelherman </h4> </div> `;
FAIL src/components/__tests__/UsersList.test.jsx ● UsersList renders a snapshot properly
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot + Received
<div> <h4 className="box title is-4" > - michael + hermanmu@gmail.com </h4> <h4 className="box title is-4" > - michaelherman + michael@mherman.org </h4> </div>
at Object.<anonymous>.test (src/components/__tests__/UsersList.test.jsx:24:16) at new Promise (<anonymous>) at Promise.resolve.then.el (node_modules/p-map/index.js:46:16) at process._tickCallback (internal/process/next_tick.js:68:7)
● UsersList renders properly
expect(received).toBe(expected)
Expected value to be (using ===): "michael" Received: "hermanmu@gmail.com"
at Object.<anonymous>.test (src/components/__tests__/UsersList.test.jsx:31:41) at new Promise (<anonymous>) at Promise.resolve.then.el (node_modules/p-map/index.js:46:16) at process._tickCallback (internal/process/next_tick.js:68:7)
Snapshot Summary › 1 snapshot test failed in 1 test suite. Inspect your code changes or press `u` to update them.
Test Suites: 1 failed, 1 total Tests: 2 failed, 2 total Snapshots: 1 failed, 1 total Time: 0.909s, estimated 1s Ran all test suites related to changed files.
Watch Usage › Press a to run all tests. › Press u to update failing snapshots. › Press p to filter by a filename regex pattern. › Press t to filter by a test name regex pattern. › Press q to quit watch mode. › Press Enter to trigger a test run.
Expected value to be (using ===): "michael" Received: "hermanmu@gmail.com"
at Object.<anonymous>.test (src/components/__tests__/UsersList.test.jsx:31:41) at new Promise (<anonymous>) at Promise.resolve.then.el (node_modules/p-map/index.js:46:16) at process._tickCallback (internal/process/next_tick.js:68:7)
Snapshot Summary › 1 snapshot updated in 1 test suite.
Test Suites: 1 failed, 1 total Tests: 1 failed, 1 passed, 2 total Snapshots: 1 updated, 1 total Time: 0.093s, estimated 1s Ran all test suites related to changed files.
console.error node_modules/fbjs/lib/warning.js:33 Warning: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. http://fb.me/react-polyfills
const react = require('react'); // Resolution for requestAnimationFrame not supported in jest error : // https://github.com/facebook/react/issues/9102#issuecomment-283873039 global.window = global; window.addEventListener = () => {}; window.requestAnimationFrame = () => { throw new Error('requestAnimationFrame is not supported in Node'); };