Comments (8)
这算是一个不成文的约定吧,比如源文件是 button.vue 或者 button.js,那么它的单元测试文件就会是 button.test.js 或者 button.spec.js 或者 button.unit.js
- button.test 比较好理解,就是测试的意思
- button.spec 中的 spec 是 specification 的缩写,表示规格,也就是 button 应该满足的规则,所以 button.spec.js 表示对 button 应该满足的规则。
- button.unit 中的 unit 就是单元测试的意思。
这么做还有一个好处,就是方面测试框架在项目中搜索所有测试文件然后运行这些文件。
比如 Karma 的配置一般我们都会写上 files: ["**/*.spec.js"]
from gulu.
另外,为什么会同时存在 .test.js 和 .spec.js
因为 .test.js 是旧的测试文件(没有使用 vue-test-utils), .spec.js 是新的测试文件(使用了 vue-test-utils)
from gulu.
感谢,不过规格这个词不太好理解,有什么例子吗,例如一个utils的工具很容易想到用test结尾,但是spec文件通常测试什么的是什么
from gulu.
这下明白了,谢谢解答,👍👍
from gulu.
不用 close,方便其他人观看。
from gulu.
另外,为什么会同时存在 .test.js 和 .spec.js 因为 .test.js 是旧的测试文件(没有使用 vue-test-utils), .spec.js 是新的测试文件(使用了 vue-test-utils)
from gulu.
@xiaorong61 一个使用了 一个没有使用啊……
from gulu.
@xiaorong61 一个使用了 一个没有使用啊……
我眼花了。。。
from gulu.
Related Issues (8)
- 大佬,UI库的 cascader-demo可以提供吗?还有没有找到表单组件。请问在哪里可以查阅呢?
- Popover组件在非自主销毁时会报 Cannot read property 'removeEventListener' of undefined HOT 1
- 二维码过期了 HOT 1
- 运行upload.spec.js失败,提示TypeError: Cannot read property 'getAttribute' of undefined HOT 1
- 记得销毁
- 现在安装parcel提示一个 warning " > [email protected]" has unmet peer dependency "webpack@^4.27.0 || ^5.0.0".
- collpase组件是有问题的, 拷贝selected时需要用一个外部并且是add和remove的公共变量
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulu.