February 2019
Beginner
694 pages
18h 4m
English
Jasmine uses a simple format for writing tests. Let's create a spec/SimpleJasmine.spec.ts file with the following TypeScript code:
describe('spec/SimpleJasmine.spec.ts', () => {
it('should fail', () => {
let undefinedValue;
expect(undefinedValue).toBeDefined('should be defined');
})
});
This snippet starts by calling the Jasmine describe function, which takes two arguments. The first argument is the name of the test suite, and the second is an anonymous function that contains each test in our test suite. Within this anonymous function, we are calling the Jasmine function named it to describe an actual test, which also takes two arguments. The first argument is the test name, and the second argument is an anonymous function ...
Read now
Unlock full access