David Muellerchen
David Muellerchen is a trainer at AngularJS.DE. He loves to speak and teach at meetups and conferences. During leisure time he jumps through the parks with his kids or rides his racer. He a
@webdave_de
describe('A suite', () => {
...
});
describe('A suite', () => {
it('contains n specs', () => {
...
});
});
describe('A suite', () => {
it('contains n specs with n expectations', () => {
expect(true).toBe(true);
});
});
describe('A suite', () => {
it('contains n specs with n expectations', () => {
expect(true).toEqual(true);
expect(true).toBe(true);
let foo: string = 'bar';
expect(foo).toBeDefined();
expect(bar).not.toBeDefined();
expect(true).toBeTruthy();
expect(false).toBeFalsy();
expect('Hi Hamburg').toMatch('Hamburg');
expect(array).toContain(value);
expect(func()).toThrow(error);
});
});
beforeAll
beforeEach
afterEach
afterAll
// is called only once before all the specs in describe are run
beforeAll(() => { ... })
// is called once before each spec in the describe in which it is called
beforeEach(() => { ... })
// is called once after each spec
afterEach(() => { ... })
// is called after all specs finish
afterAll(() => { ... })
https://jasmine.github.io/2.5/introduction
https://karma-runner.github.io/1.0/index.html
// npm install jasmine-expect karma-jasmine-matchers --save-dev
// karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: [
'jasmine',
'angular-cli',
'jasmine-matchers' //<=
],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-matchers'), //<=
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
],
...
});
};
https://github.com/JamieMason/Jasmine-Matchers
https://github.com/web-dave/testing_meetup_hh
https://medium.com/google-developer-experts/angular-2-testing-guide-a485b6cb1ef0
https://angularjs.de/artikel/angularjs-test
By David Muellerchen
David Muellerchen is a trainer at AngularJS.DE. He loves to speak and teach at meetups and conferences. During leisure time he jumps through the parks with his kids or rides his racer. He a