Skip to content

Commit ec53f1a

Browse files
add tests for before hooks
1 parent 44a0cf8 commit ec53f1a

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

integration_tests/__tests__/jasmine_async.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ describe('async jasmine', () => {
1919
]);
2020
const json = result.json;
2121

22-
expect(json.numTotalTests).toBe(2);
22+
expect(json.numTotalTests).toBe(4);
2323
expect(json.numPassedTests).toBe(1);
24-
expect(json.numFailedTests).toBe(1);
24+
expect(json.numFailedTests).toBe(3);
2525
expect(json.numPendingTests).toBe(0);
2626

2727
const {message} = json.testResults[0];
2828
expect(message).toMatch('with failing timeout');
2929
expect(message).toMatch('Async callback was not invoked within timeout');
30+
expect(message).toMatch('done - with error thrown');
31+
expect(message).toMatch('done - with error called back');
3032
});
3133

3234
it('works with beforeEach', () => {
@@ -35,11 +37,14 @@ describe('async jasmine', () => {
3537
]);
3638
const json = result.json;
3739

38-
expect(json.numTotalTests).toBe(1);
40+
expect(json.numTotalTests).toBe(3);
3941
expect(json.numPassedTests).toBe(1);
40-
expect(json.numFailedTests).toBe(0);
42+
expect(json.numFailedTests).toBe(2);
4143
expect(json.numPendingTests).toBe(0);
42-
expect(json.testResults[0].message).toBe('');
44+
45+
const {message} = json.testResults[0];
46+
expect(message).toMatch('done - with error thrown');
47+
expect(message).toMatch('done - with error called back');
4348
});
4449

4550
it('works with afterAll', () => {

integration_tests/jasmine_async/__tests__/promise_before_all.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,19 @@ describe('promise beforeAll', () => {
3434

3535
it('fails', () => {});
3636
});
37+
38+
describe('done - with error thrown', () => {
39+
beforeAll(done => {
40+
throw new Error('fail');
41+
done(); // eslint-disable-line
42+
});
43+
it('fails', () => {});
44+
});
45+
46+
describe('done - with error called back', () => {
47+
beforeAll(done => {
48+
done(new Error('fail'));
49+
});
50+
it('fails', () => {});
51+
});
3752
});

integration_tests/jasmine_async/__tests__/promise_before_each.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,20 @@ describe('promise beforeEach', () => {
2121
it('runs tests after beforeEach asynchronously completes', () => {
2222
expect(this.flag).toBe(1);
2323
});
24+
25+
// failing tests
26+
describe('done - with error thrown', () => {
27+
beforeEach(done => {
28+
throw new Error('fail');
29+
done(); // eslint-disable-line
30+
});
31+
it('fails', () => {});
32+
});
33+
34+
describe('done - with error called back', () => {
35+
beforeEach(done => {
36+
done(new Error('fail'));
37+
});
38+
it('fails', () => {});
39+
});
2440
});

0 commit comments

Comments
 (0)