Giter Site home page Giter Site logo

Comments (8)

FrankFang avatar FrankFang commented on July 26, 2024 42

这算是一个不成文的约定吧,比如源文件是 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.

FrankFang avatar FrankFang commented on July 26, 2024 6

另外,为什么会同时存在 .test.js 和 .spec.js
因为 .test.js 是旧的测试文件(没有使用 vue-test-utils), .spec.js 是新的测试文件(使用了 vue-test-utils)

from gulu.

bosens-China avatar bosens-China commented on July 26, 2024 1

感谢,不过规格这个词不太好理解,有什么例子吗,例如一个utils的工具很容易想到用test结尾,但是spec文件通常测试什么的是什么

from gulu.

mengsixing avatar mengsixing commented on July 26, 2024

这下明白了,谢谢解答,👍👍

from gulu.

FrankFang avatar FrankFang commented on July 26, 2024

不用 close,方便其他人观看。

from gulu.

xiaorong61 avatar xiaorong61 commented on July 26, 2024

另外,为什么会同时存在 .test.js 和 .spec.js 因为 .test.js 是旧的测试文件(没有使用 vue-test-utils), .spec.js 是新的测试文件(使用了 vue-test-utils)

image
这不是一样的么........

from gulu.

FrankFang avatar FrankFang commented on July 26, 2024

@xiaorong61 一个使用了 一个没有使用啊……

from gulu.

xiaorong61 avatar xiaorong61 commented on July 26, 2024

@xiaorong61 一个使用了 一个没有使用啊……

我眼花了。。。

from gulu.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.