Filename Conventions
Each unit test is put into its own separate file. The Angular team recommends putting unit test scripts alongside the files they are testing and using a .spec
filename extension to mark it as a testing script (this is a Jasmine convention). So if you had a component /app/components/mycomponent.ts
, then your unit test for this component would be in /app/components/mycomponent.spec.ts
. This is a matter of personal preference; you can put your testing scripts wherever you like, though keeping them close to your source files makes them easier to find and gives those who aren't familiar with the source code an idea of how that particular piece of code should work.
Last updated