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

Animate.js 的 defaultKey 的生成方式导致 jest mock 的 Date.now 无法起作用 #32

Closed
someok opened this issue Oct 8, 2017 · 2 comments

Comments

@someok
Copy link

someok commented Oct 8, 2017

这个问题是在使用 jesttoMatchSnapshot 时候发现的,debug 了一下发现是下面语句无论如何都会在 mock 的Date.now = jest.fn(() => 1507453184412) 之前执行,所以建议这个语句是不是应该放到 Animate.js class 的内部更好?

const defaultKey = `rc_animate_${Date.now()}`;

@benjycui
Copy link
Member

benjycui commented Oct 9, 2017

setupFiles.

@benjycui benjycui closed this as completed Oct 9, 2017
@someok
Copy link
Author

someok commented Oct 9, 2017

其实不能用 setupFiles 来处理,毕竟这个 Date 的 mock 只是在某个测试中使用。

应该使用 enzyme-to-jsonnoKey 属性

import toJson from 'enzyme-to-json';

expect(toJson(wrapper, {noKey: true})).toMatchSnapshot();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants