FEAT: Front-End Auto Testing
FEAT
FEAT: Front-End Auto Testing
前端自动化测试
jest
$ yarn add -D jest
# OR
$ npm i -D jest
https://jestjs.io/docs/en/getting-started
https://jestjs.io/docs/en/cli.html#coverage
https://jestjs.io/docs/en/mock-functions.html
https://jestjs.io/docs/en/using-matchers
demo
sum.js
const sum = (a = 0, b = 0) => {
return a + b;
};
default export sum;
sum..test.js
import * as sum from("./sum");
test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
});
package.json
{
"scripts": {
"test": "jest"
}
}
shell
$ yarn test
# or
$ npm run test
babel & jest
expect
https://jestjs.io/docs/en/expect
// todo...
asynchronous
Promise & Async / Await
https://jestjs.io/docs/en/asynchronous
// todo...
TDD
Test-Drive Development 测试驱动开发
- React + TypeScript
- gulp + mocha + enzyme
https://www.cnblogs.com/BestMePeng/p/react_ts_tdd.html
https://github.com/Penggggg/tdd-demo
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/10539077.html
未经授权禁止转载,违者必究!