Add option to just see generated code
Closed this issue · 5 comments
When generating test and there is a existing test file we are asked if we want to replace it. It would be nice to have the option to just see the generated test in a new file.
Brainstorm with me. I have a problem with the way overlays work in VSCode, they're too clunky. How about if it gives you the option of saving to a separate file? It could work in one of two ways:
- Use
.generated
and overwrite every time. I like this option. Forapp.component.ts
, if there's alreadyapp.component.spec.ts
it will createapp.component.generated.spec.ts
(overwriting it if it exists). - Use an incrementing numeric system without overwriting files:
app.component.1.spec.ts
,.2.spect.ts
, etc.
What do you think? Do you have another option?
I´m not sure but I think that approach 2 would be a good way to go.. both will run when running tests with angular cli, but using the second approach also allows users to use the test generator to just add more separated tests.
The problem I have with 2 is the very likely possibility of devs either going through the trouble of deleting generated test files or worse, leaving redundant tests around.
hmm.. not sure I see it as a problem really :P
This is how v0.14.0 works: If there's a .spec.ts
file, it will save a .gen.spec.ts
one and warn you about it. If there's already a .gen.spec.ts
it will ask if you want to replace it. That way you can generate .gen
files just to see the changes, incorporate them into the (true) .spec
one, then probably delete the .gen
.
The reason is that in my experience the first .spec.ts
file is just the starting point for testing (the boilerplate if you will). It's a rare component that I generate the test and leave it as it was generated.