Angular Unit Testing Snippets for VSCode (Angular 2+)
Visual Studio Code Angular Unit Testing Snippets in Jasmine
These snippets were created after observing that, these code blocks / mocks / techniques were used a lot while we write unit tests in angular.
If you want to learn angular unit testing. Please refer https://angular.io/guide/testing
Type jat- to get the snippet intellisense. Press enter to select a snippet
||Unfold the unit test setup for component (Runs in isolation)
||Component unit test setup with a sample mock service (Runs in isolation)
||Mock service which returns an observable, to use in useClass provider
||Generates a jasmine describe block (Test suite)
||Generates an it block (Test spec)
||Generates a it block to test the methods which contains timers (SetTimeout, SetInterval etc)
||Angular useValue provider to inject mock value as dependency instead of an injection token or injected service.
||Angular useClass provider to inject a mock class as dependency instead of an injection token or injected service.
||Mock Class to use as a mock for the injected Router class (Has minimal methods like navigate, navigateByUrl etc. These can be extended)