Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp key in mock function lead to fail snapshot test #164

Closed
Serzh470 opened this issue Dec 3, 2019 · 1 comment
Closed

Timestamp key in mock function lead to fail snapshot test #164

Serzh470 opened this issue Dec 3, 2019 · 1 comment
Labels
invalid An issue that is not an issue

Comments

@Serzh470
Copy link

Serzh470 commented Dec 3, 2019

When snapshot generated, there is timestamp in mock function generated. On the next test run snapshot fails, because of timestamps difference:
Jest output:

    - Snapshot
    + Received

    @@ -11753,11 +11753,11 @@
                          3/6
                        </div>
                      </div>
                    </div>
                  </div>,
    -             "timeStamp": 1575362573116,
    +             "timeStamp": 1575363216180,
                  "type": "click",
                },
              ],
            ],
            "results": Array [

      29 | 
      30 |         it("renders properly", () => {
    > 31 |             expect(wrapper).toMatchSnapshot();
         |                             ^
      32 |         });

Snaphot code:

...
              </div>
            </div>,
            "timeStamp": 1575362573116,
            "type": "click",
          },
        ],
      ],
...

Packages versions:

"jest": "^24.8.0",
"jest-environment-jsdom-fourteen": "^0.1.0",
"babel-jest": "^24.8.0",
"eslint-plugin-jest": "^23.0.5",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"enzyme-to-json": "^3.4.3",
@adriantoine
Copy link
Owner

Hi,

This is not an issue with this library, you need to find a way to mock the current date. There are several ways, see jestjs/jest#2234 or this post.

@adriantoine adriantoine added the invalid An issue that is not an issue label Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid An issue that is not an issue
Projects
None yet
Development

No branches or pull requests

2 participants