Angular CLI create .spec files for already existing components
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.
chose a directory where you want to generate spec, and then it will generate all Angular spec.
only generate file when spec file not exist, and the component / directive / guard / pipe / service follow the angular-cli file generate name.
npm install -g angular-spec-generator
angular-spec-generator 'C:\Users\Alan\Desktop\test'