-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Testing #921
Testing #921
Conversation
native demo 的 snapshot 测试还要研究下。 |
components/button/index.tsx
Outdated
if (!this.props.disabled) { | ||
this.setState({ pressIn: true }); | ||
} | ||
if (this.props.onPressIn) { | ||
this.props.onPressIn(arg); | ||
(this.props.onPressIn as any)(...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里原来参数传错了,下面也一样。
components/button/index.tsx
Outdated
@@ -102,7 +103,6 @@ export default class Button extends React.Component<tsProps, any> { | |||
onShowUnderlay={this.onShowUnderlay} | |||
onHideUnderlay={this.onHideUnderlay} | |||
disabled={disabled} | |||
{...restProps} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{...restProps}
写在下面会导致把上面的 onPressIn={this.onPressIn}
等覆盖掉。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restprops 要把 onpressXX 过滤掉, 我来处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silentcloud OK,你改完 master 我再 rebase。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silentcloud 这个 master 上还没改掉。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个我来改吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
奥,已经改掉了。
f42d782
to
b6c0a14
Compare
本来想 web 组件和 RN 组件一起跑测试的,但是发现把 web 和 RN 环境混在一起有很多问题,现在的方案是分开来跑,引入两个命令 |
不行,不只有总覆盖率。 |
|
决定分开来统计, |
这里有个坑是有些代码是复用的... |
有些rn组件会引用.web代码,有些甚至不区分.web |
举个例子? |
我手机不太方便,你可以找几个组件看一眼,真要区分估计要维护一份配置列表...这就有点尴尬了 |
底层依赖 picker date-picker 没区分文件名后缀,如 https://github.com/react-component/m-date-picker/blob/master/src/Popup.tsx cc @yiminghe |
底层依赖没关系,这边的测试不测底层依赖的。 |
c9fd8a5
to
eb5b2b7
Compare
这样的话,web 组件的覆盖率会偏高一点,但是 RN 组件的覆盖率是正常的。共享的代码在 web 测试里统计不到,在 RN 测试里会统计到。感觉关系不大。 |
也不能说 web 测试的覆盖率会偏高吧,只是说 web 测试的覆盖率会有少统计。 |
@warmhug 为了让覆盖率准确, |
这样没用的,现在是按文件后缀名区分的。 |
@yesmeck 哪尼? 代码覆盖率计算不会这样吧,Import的内容不算? |
https://github.com/ant-design/ant-design-mobile/blob/testing/.jest.web.json#L26-L29 其实关系不大的,web 测试少统计的文件,在 RN 测试里会统计进去。覆盖率本来就是参考性的东西。 |
@yesmeck ok,优先把测试的流程run起来 |
9d728dc
to
c4a174e
Compare
Codecov Report
@@ Coverage Diff @@
## master #921 +/- ##
=========================================
Coverage ? 60.71%
=========================================
Files ? 259
Lines ? 4612
Branches ? 1299
=========================================
Hits ? 2800
Misses ? 1811
Partials ? 1
Continue to review full report at Codecov.
|
2b73eb9
to
cfbcc7a
Compare
Great! Codecov 能合并两个覆盖率报告。 |
antd 也转 codecov 好了。 |
更新了描述,暂时把 snap 文件删掉了,ready to merge。 |
@yesmeck 这个可以合了吗? |
可以合并。 |
@yesmeck 7 个commit不需要合吗? |
自动会合的。 |
@yesmeck 会保留你所有的commit log在注释里... 还是手动合一下吧 |
这不是很好吗。。把做了什么事都记下来。 |
#900
npm test
改成了只用来跑测试;npm run test:web
跑 web 组件测试,npm run test:rn
跑 rn 组件测试;.web.js
后缀;snapshot 的简单用法:
npm run test:[web/rn] -- -u
来自动更新 snapshot;碰到的问题/注意的点:
react-test-renderer
来做 snapshot 的测试,而 web 的组件是用enzyme
的render
+enzyme-to-json
做的;enzyme
的shallow
,不能用mount
和render
;