title: Jest React - New snapshot was not written. The update flag must be explicitly passed to write a new snapshot
body: <p>I have a asp.net core project created with React template, trying to unit test a simple component with Jest snapshot and I am receiving below error.Can any one suggest how to fix it.</p>
  
  <h1><strong>index.js</strong></h1>
  
  <pre><code>import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
  import { Button } from 'reactstrap'
  
  const CloseHistoryButton = ({ onClick }) =&gt;
      &lt;div className="d-flex justify-content-end"&gt;
          &lt;Button color="danger" size="sm" onClick={onClick}&gt;
              &lt;FontAwesomeIcon icon="times" /&gt; Close History
          &lt;/Button&gt;
      &lt;/div&gt;
  
  export default CloseHistoryButton  
  </code></pre>
  
  <h1><strong>CloseHistoryButton.test</strong></h1>
  
  <pre><code>import ReactDOM from 'react-dom';
  import { shallow, mount, render } from 'enzyme';
  import { cleanup } from '@testing-library/react';
  import renderer from 'react-test-renderer';
  import CloseHistoryButton from '../CloseHistoryButton/index';
  import registerIcons from './../../../../icons/registerIcons';
  import Enzyme from 'enzyme';
  import Adapter from 'enzyme-adapter-react-16';
  Enzyme.configure({ adapter: new Adapter() });
  
  // automatically unmount and cleanup DOM after the test is finished.
  afterEach(cleanup);
  registerIcons();
  test('renders correctly', () =&gt; {
      const tree = renderer.create(
                                  &lt;CloseHistoryButton /&gt;
                                  ).toJSON();
      expect(tree).toMatchSnapshot();
  });
  
  </code></pre>
  
  <h1>Error Log:</h1>
  
  <p>expect(received).toMatchSnapshot()</p>
  
  <pre><code>New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.
  
  This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.
  
  Received value
  &lt;div
    className="d-flex justify-content-end"
  &gt;
    &lt;button
      aria-label={null}
      className="btn btn-danger btn-sm"
      onClick={[Function]}
    &gt;
      &lt;svg
        aria-hidden="true"
        className="svg-inline--fa fa-times fa-w-11 "
        data-icon="times"
        data-prefix="fas"
        focusable="false"
        role="img"
        style={Object {}}
        viewBox="0 0 352 512"
        xmlns="http://www.w3.org/2000/svg"
      &gt;
        &lt;path
          d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
          fill="currentColor"
          style={Object {}}
        /&gt;
      &lt;/svg&gt;
       Close History
    &lt;/button&gt;
  &lt;/div&gt;
  
    27 |                                 &lt;CloseHistoryButton /&gt;
    28 |                                 ).toJSON();
  &gt; 29 |     expect(tree).toMatchSnapshot();
       |                  ^
    30 | });
    31 |
    32 | describe('Test Button component', () =&gt; {
  
    at Object.toMatchSnapshot (src/features/FleetImport/Results/CloseHistoryButton/CloseHistoryButton.test.js:29:18)
  </code></pre>
  
  <p>› 1 snapshot failed.
  Snapshot Summary
   › 1 snapshot failed from 1 test suite. Inspect your code changes or re-run jest with <code>-u</code> to update them.</p>
  
  <p>Test Suites: 1 failed, 1 passed, 2 total
  Tests:       1 failed, 3 passed, 4 total
  Snapshots:   1 failed, 1 total
  Time:        4.338s
  Ran all test suites.
  npm ERR! Test failed.  See above for more details.</p>