-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.component.spec.ts
36 lines (30 loc) · 780 Bytes
/
app.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {addEventHandler} from "jest-circus/build/state";
// a global spy to listen to hooks
const spy = jest.fn();
spy.mockName('suite listener');
// an attempt to use hooks
addEventHandler(spy);
// it works with testRunner: 'jest-jasmine2',
declare const jasmine: any;
if (typeof jasmine !== 'undefined') {
jasmine.getEnv().addReporter({
jasmineDone:spy,
jasmineStarted:spy,
specDone:spy,
specStarted:spy,
suiteDone:spy,
suiteStarted:spy,
});
}
// simulating some hooks calls
describe('main block', () => {
describe('sub block', () => {
it('simulates positive', () => {
expect(1).toEqual(1);
});
});
// assertion that hooks are called on the spy too
it('uses listener', () => {
expect(spy).toHaveBeenCalled();
})
});