Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI create .spec files for already existing components

There is an option in .angular-cli.json to disable the automatic creating of *.spec files e.g. for components, see json schema.

This is a really nice feature because personally (this is just my opinion) testing the components might not be the thing that really worth it in a fast growing project.

However sometimes I would like to have an option to generate / recreate the corresponding *.spec file for an already existing component / service / pipe / whatsoever.

Is that possible using some command line call?

Created a feature request, let's see how it goes...

like image 444
smnbbrv Avatar asked Sep 18 '17 09:09

smnbbrv


People also ask

How do I create a spec TS file?

Select an Angular *. ts file and use right click to generate the spec file. Generate spec (jest / jasmine / mockito / empty) files for Angular elements: component.

What is .spec file in angular?

This file contains unit tests for the main AppComponent. When running tests using the Angular CLI, all unit tests in files with the *. spec.


1 Answers

Currently Angular CLI does not provide this functionality and it is not clear how and when it will be possible to manage it in official way.

However, here is a library "ngx-spec" that generates the spec based on Angular CLI spec presets.

like image 157
smnbbrv Avatar answered Sep 21 '22 08:09

smnbbrv