👨🏫 Co-Founder of This is Learning, Organizer of AarhusJS
✍️ Writer, Speaker, FOSS Maintainer 📗 Author
🏆 Microsoft MVP 🌟 GitHub Star
🌊 Nx Champion 🦸 Angular Hero of Education
Oh, you mean having to setup all the needed Angular module imports and declarations? Are you aware of SCAMs?
One advantage is that you can often just import a component's SCAM to test it. It's so unexpectedly easy that Spectator had to put in a special option to undo some of its normal affordances to make component tests easier to set up.
👨🏫 Co-Founder of This is Learning, Organizer of AarhusJS
✍️ Writer, Speaker, FOSS Maintainer 📗 Author
🏆 Microsoft MVP 🌟 GitHub Star
🌊 Nx Champion 🦸 Angular Hero of Education
Thanks. Of course, there's also the option to use shallow component tests, where we include no or only some view child components in our tests: angular.io/guide/testing#nested-co...
👨🏫 Co-Founder of This is Learning, Organizer of AarhusJS
✍️ Writer, Speaker, FOSS Maintainer 📗 Author
🏆 Microsoft MVP 🌟 GitHub Star
🌊 Nx Champion 🦸 Angular Hero of Education
Pretty much every Angular component have these files.
Honestly, It's like the Angular team didn't test it at all with lots of components in a module.
Are there any alternatives to that doesn't involve adding recreating the module in every file?
It's not only the speed, but having to recreate the module code for every test file is also a pain.
Oh, you mean having to setup all the needed Angular module imports and declarations? Are you aware of SCAMs?
One advantage is that you can often just import a component's SCAM to test it. It's so unexpectedly easy that Spectator had to put in a special option to undo some of its normal affordances to make component tests easier to set up.
I'm not aware of that. Too late for existing apps probably.
But looks useful for new apps.
I already refactored the TestBed to its own function so it can be imported and run anywhere, that's how I solved it.
Thanks. Of course, there's also the option to use shallow component tests, where we include no or only some view child components in our tests:
angular.io/guide/testing#nested-co...
But we still have to put dependencies in
declarations
right?Not with shallow components tests using
NO_ERRORS_SCHEMA
.That's great. It's annoying to have to put everything in the TestBed module.
Anything in Angular is more complex than the other frameworks.