AngularJS unit test directory structure Best Practices

What is the best practice to follow to create the directory structure for unit tests when using AngularJS for eg in general following struct

As mentioned in the link https://scotch.io/tutorials/angularjs-best-practices-directory-structure

What should be the structure to place the unit test files in...if it's an MVC Visual Studio project, should it be in the separate unit test project?


According to the Google Best practice which has similar grouping by component you would have the tests in the same folder as the item under test. To keep the same naming convention you would name the tests like homeControllerTest.js or you could use homeController_test.js


Putting them side-by-side with the file under test seems to be recommended.

For example:

folder/
  file.js
  file.spec.js
  otherfile.js
  otherfile.spec.js

This recommendation comes from a very good style guide found here: https://github.com/johnpapa/angular-styleguide#style-y197

链接地址: http://www.djcxy.com/p/39118.html

上一篇: 单元测试AngularJS控制器,同时遵循最佳实践

下一篇: AngularJS单元测试目录结构最佳实践