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

Introduce jest and enzyme #136

Merged
merged 1 commit into from
Nov 25, 2016
Merged

Conversation

yesmeck
Copy link
Member

@yesmeck yesmeck commented Nov 14, 2016

mocha 迁移到 jest 只要调整下 expect 的写法,这里只转换了一部分,看看行不行。

运行:npm run jest

done();
});
});

it('should add css class of root dom node', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

像这种 DOM 结构是不是渲染正确的,直接用 snapshot 测试,可以省事很多,而且覆盖率也更高。

const input = TestUtils.findRenderedDOMComponentWithTag(instance, 'input');
);

const input = wrapper.find('input');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enzyme 之于 React 就像 jQuery 之于 DOM,操作 Component 会简单很多。

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 78.776% when pulling 92d8380 on yesmeck:introduce-jest into 3ada48a on react-component:master.

@yiminghe
Copy link
Member

coverage 怎么搞?

@yesmeck
Copy link
Member Author

yesmeck commented Nov 15, 2016

jest 自带了的 npm run jest -- --coverage

@yiminghe
Copy link
Member

可以,全部改了,改好我合并

@yiminghe
Copy link
Member

注意 coveralls.io 能否正确运行

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.6%) to 73.153% when pulling 2d49bb9 on yesmeck:introduce-jest into 3ada48a on react-component:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.6%) to 73.153% when pulling 6d572aa on yesmeck:introduce-jest into 3ada48a on react-component:master.

@yesmeck
Copy link
Member Author

yesmeck commented Nov 18, 2016

这边已经把所有 expect 的写法都改了,具体测试现在用 jQuery 来写的地方我看情况后面补测试的时候再调整为 enzyme 和 snapshot。

coverage 的计算结果要比原来的低,暂时不知道为什么。

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.6%) to 73.153% when pulling 6d572aa on yesmeck:introduce-jest into 3ada48a on react-component:master.

@yiminghe
Copy link
Member

改完需要合并时通知

@yesmeck
Copy link
Member Author

yesmeck commented Nov 24, 2016

已经改完了,这个可以合并了。

我后面补的测试再另外 PR。

@yiminghe yiminghe merged commit d8e4fd4 into react-component:master Nov 25, 2016
@yiminghe
Copy link
Member

貌似不能 npm run chrome-test 浏览器中调试了...

node --debug node_modules/bin/jest

能用么

@yesmeck
Copy link
Member Author

yesmeck commented Nov 25, 2016

这样是可以的:

node debug node_modules/.bin/jest -i  tests/Combobox.spec.js`

这样有问题 jestjs/jest#1652

node --inspect node_modules/.bin/jest -i  tests/Combobox.spec.js

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

Successfully merging this pull request may close these issues.

3 participants