Jasmine test
Last updated
Was this helpful?
Last updated
Was this helpful?
Very good introduction to Jasmine
Video explanation : talk about unit test, what is it, test in general... The jasmine Documentation
Run before all test suite tests
beforeAll
afterAll
Run before each test, before this test or after this test
beforeEach
afterEach
Put x in front of describe (the test suite = group of tests) xdesribe
and x in front of it (the test) so xit
It allows to disable a test temporarily though still listing it and not commenting it To be able to see the test code.
Put f in front of it to focus only on one test (only run one test) so write fit('the test to focus on')
A test suite : a group of test (describe)
A test spec : one individual test (it)
A test expectation : what we are testing (expect)
Karma is a test runner, it is not compulsory to use it. Though it is easier :
It reruns the tests when code change
It open a separate browser (headless)
It gets Jasmine result in the command line
Error due to a missing selector with debugElement
Failed: Uncaught (in promise): TypeError: Cannot read property 'nativeElement' of undefined
angular test with data that come from a resolver
Jasmine doc on spies
Jasmine Spy spreadsheet
Duplication using a way to invoke describe by using a function
Git that explain why using this in the test context. Some recent comment explained how to use it with typescript as well.
Discussion about how to write units tests with multiple expect in it or not, parameterized tests...
Example of parameterized test in JavaScript