jasmine-core 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,21 +14,63 @@ describe("j$.pp", function () {
14
14
  expect(j$.pp(-0)).toEqual("-0");
15
15
  });
16
16
 
17
- it("should stringify arrays properly", function() {
18
- expect(j$.pp([1, 2])).toEqual("[ 1, 2 ]");
19
- expect(j$.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', Object({ }), undefined, null ]");
20
- });
21
-
22
- it("should indicate circular array references", function() {
23
- var array1 = [1, 2];
24
- var array2 = [array1];
25
- array1.push(array2);
26
- expect(j$.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
27
- });
28
-
29
- it("should not indicate circular references incorrectly", function() {
30
- var array = [ [1] ];
31
- expect(j$.pp(array)).toEqual("[ [ 1 ] ]");
17
+ describe('stringify arrays', function() {
18
+ it("should stringify arrays properly", function() {
19
+ expect(j$.pp([1, 2])).toEqual("[ 1, 2 ]");
20
+ expect(j$.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', Object({ }), undefined, null ]");
21
+ });
22
+
23
+ it("should truncate arrays that are longer than j$.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
24
+ var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
25
+ var array = [1, 2, 3];
26
+
27
+ try {
28
+ j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
29
+ expect(j$.pp(array)).toEqual("[ 1, 2, ... ]");
30
+ } finally {
31
+ j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
32
+ }
33
+ });
34
+
35
+ it("should stringify arrays with properties properly", function() {
36
+ var arr = [1, 2];
37
+ arr.foo = 'bar';
38
+ arr.baz = {};
39
+ expect(j$.pp(arr)).toEqual("[ 1, 2, foo: 'bar', baz: Object({ }) ]");
40
+ });
41
+
42
+ it("should stringify empty arrays with properties properly", function() {
43
+ var empty = [];
44
+ empty.foo = 'bar';
45
+ empty.baz = {};
46
+ expect(j$.pp(empty)).toEqual("[ foo: 'bar', baz: Object({ }) ]");
47
+ });
48
+
49
+ it("should stringify long arrays with properties properly", function() {
50
+ var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
51
+ var long = [1,2,3];
52
+ long.foo = 'bar';
53
+ long.baz = {};
54
+
55
+ try {
56
+ j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
57
+ expect(j$.pp(long)).toEqual("[ 1, 2, ..., foo: 'bar', baz: Object({ }) ]");
58
+ } finally {
59
+ j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
60
+ }
61
+ });
62
+
63
+ it("should indicate circular array references", function() {
64
+ var array1 = [1, 2];
65
+ var array2 = [array1];
66
+ array1.push(array2);
67
+ expect(j$.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
68
+ });
69
+
70
+ it("should not indicate circular references incorrectly", function() {
71
+ var array = [ [1] ];
72
+ expect(j$.pp(array)).toEqual("[ [ 1 ] ]");
73
+ });
32
74
  });
33
75
 
34
76
  it("should stringify objects properly", function() {
@@ -77,18 +119,6 @@ describe("j$.pp", function () {
77
119
  }
78
120
  });
79
121
 
80
- it("should truncate arrays that are longer than j$.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
81
- var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
82
- var array = [1, 2, 3];
83
-
84
- try {
85
- j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
86
- expect(j$.pp(array)).toEqual("[ 1, 2, ... ]");
87
- } finally {
88
- j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
89
- }
90
- });
91
-
92
122
  it("should stringify RegExp objects properly", function() {
93
123
  expect(j$.pp(/x|y|z/)).toEqual("/x|y|z/");
94
124
  });
@@ -148,6 +148,29 @@ describe("Spec", function() {
148
148
  expect(resultCallback).toHaveBeenCalled();
149
149
  });
150
150
 
151
+ it("can be disabled at execution time by a parent", function() {
152
+ var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
153
+ startCallback = jasmine.createSpy('startCallback'),
154
+ specBody = jasmine.createSpy('specBody'),
155
+ resultCallback = jasmine.createSpy('resultCallback'),
156
+ spec = new j$.Spec({
157
+ onStart:startCallback,
158
+ queueableFn: { fn: specBody },
159
+ resultCallback: resultCallback,
160
+ queueRunnerFactory: fakeQueueRunner
161
+ });
162
+
163
+ spec.execute(undefined, false);
164
+
165
+ expect(spec.result.status).toBe('disabled');
166
+
167
+ expect(fakeQueueRunner).not.toHaveBeenCalled();
168
+ expect(specBody).not.toHaveBeenCalled();
169
+
170
+ expect(startCallback).toHaveBeenCalled();
171
+ expect(resultCallback).toHaveBeenCalled();
172
+ });
173
+
151
174
  it("can be marked pending, but still calls callbacks when executed", function() {
152
175
  var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
153
176
  startCallback = jasmine.createSpy('startCallback'),
@@ -232,6 +255,40 @@ describe("Spec", function() {
232
255
  expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['expectation2']);
233
256
  });
234
257
 
258
+ it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() {
259
+ var resultCallback = jasmine.createSpy('resultCallback'),
260
+ spec = new j$.Spec({
261
+ queueableFn: { fn: function() {} },
262
+ expectationResultFactory: function(data) { return data; },
263
+ queueRunnerFactory: function(attrs) { attrs.onComplete(); },
264
+ resultCallback: resultCallback,
265
+ throwOnExpectationFailure: true
266
+ });
267
+
268
+ spec.addExpectationResult(true, 'passed');
269
+ expect(function() {
270
+ spec.addExpectationResult(false, 'failed')
271
+ }).toThrowError(j$.errors.ExpectationFailed);
272
+
273
+ spec.execute();
274
+
275
+ expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['passed']);
276
+ expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['failed']);
277
+ });
278
+
279
+ it("does not throw an ExpectationFailed error when handling an error", function() {
280
+ var resultCallback = jasmine.createSpy('resultCallback'),
281
+ spec = new j$.Spec({
282
+ queueableFn: { fn: function() {} },
283
+ expectationResultFactory: function(data) { return data; },
284
+ queueRunnerFactory: function(attrs) { attrs.onComplete(); },
285
+ resultCallback: resultCallback,
286
+ throwOnExpectationFailure: true
287
+ });
288
+
289
+ spec.onException('failing exception');
290
+ });
291
+
235
292
  it("can return its full name", function() {
236
293
  var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
237
294
 
@@ -244,7 +301,7 @@ describe("Spec", function() {
244
301
  expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
245
302
  });
246
303
 
247
- describe("when a spec is marked pending during execution", function() {
304
+ describe("when a spec is marked pending during execution", function() {
248
305
  it("should mark the spec as pending", function() {
249
306
  var fakeQueueRunner = function(opts) {
250
307
  opts.onException(new Error(j$.Spec.pendingSpecExceptionMessage));
@@ -279,4 +336,86 @@ describe("Spec", function() {
279
336
  expect(spec.result.pendingReason).toEqual('custom message');
280
337
  });
281
338
  });
339
+
340
+ it("should log a failure when handling an exception", function() {
341
+ var resultCallback = jasmine.createSpy('resultCallback'),
342
+ spec = new j$.Spec({
343
+ queueableFn: { fn: function() {} },
344
+ expectationResultFactory: function(data) { return data; },
345
+ queueRunnerFactory: function(attrs) { attrs.onComplete(); },
346
+ resultCallback: resultCallback
347
+ });
348
+
349
+ spec.onException('foo');
350
+ spec.execute();
351
+
352
+ expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([{
353
+ error: 'foo',
354
+ matcherName: '',
355
+ passed: false,
356
+ expected: '',
357
+ actual: ''
358
+ }]);
359
+ });
360
+
361
+ it("should not log an additional failure when handling an ExpectationFailed error", function() {
362
+ var resultCallback = jasmine.createSpy('resultCallback'),
363
+ spec = new j$.Spec({
364
+ queueableFn: { fn: function() {} },
365
+ expectationResultFactory: function(data) { return data; },
366
+ queueRunnerFactory: function(attrs) { attrs.onComplete(); },
367
+ resultCallback: resultCallback
368
+ });
369
+
370
+ spec.onException(new j$.errors.ExpectationFailed());
371
+ spec.execute();
372
+
373
+ expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
374
+ });
375
+
376
+ it("retrieves a result with updated status", function() {
377
+ var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
378
+
379
+ expect(spec.getResult().status).toBe('passed');
380
+ });
381
+
382
+ it("retrives a result with disabled status", function() {
383
+ var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
384
+ spec.disable();
385
+
386
+ expect(spec.getResult().status).toBe('disabled');
387
+ });
388
+
389
+ it("retrives a result with pending status", function() {
390
+ var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
391
+ spec.pend();
392
+
393
+ expect(spec.getResult().status).toBe('pending');
394
+ });
395
+
396
+ it("should not be executable when disabled", function() {
397
+ var spec = new j$.Spec({
398
+ queueableFn: { fn: function() {} }
399
+ });
400
+ spec.disable();
401
+
402
+ expect(spec.isExecutable()).toBe(false);
403
+ });
404
+
405
+ it("should not be executable when pending", function() {
406
+ var spec = new j$.Spec({
407
+ queueableFn: { fn: function() {} }
408
+ });
409
+ spec.pend();
410
+
411
+ expect(spec.isExecutable()).toBe(false);
412
+ });
413
+
414
+ it("should be executable when not disabled or pending", function() {
415
+ var spec = new j$.Spec({
416
+ queueableFn: { fn: function() {} }
417
+ });
418
+
419
+ expect(spec.isExecutable()).toBe(true);
420
+ });
282
421
  });
@@ -52,31 +52,6 @@ describe("Suite", function() {
52
52
  expect(suite.beforeFns).toEqual([innerBefore, outerBefore]);
53
53
  });
54
54
 
55
- it("runs beforeAll functions in order of needed execution", function() {
56
- var env = new j$.Env(),
57
- fakeQueueRunner = jasmine.createSpy('fake queue runner'),
58
- suite = new j$.Suite({
59
- env: env,
60
- description: "I am a suite",
61
- queueRunner: fakeQueueRunner
62
- }),
63
- firstBefore = jasmine.createSpy('outerBeforeAll'),
64
- lastBefore = jasmine.createSpy('insideBeforeAll'),
65
- fakeIt = {execute: jasmine.createSpy('it'), isExecutable: function() { return true; } };
66
-
67
- suite.beforeAll(firstBefore);
68
- suite.beforeAll(lastBefore);
69
- suite.addChild(fakeIt);
70
-
71
- suite.execute();
72
- var suiteFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
73
-
74
- suiteFns[0]();
75
- expect(firstBefore).toHaveBeenCalled();
76
- suiteFns[1]();
77
- expect(lastBefore).toHaveBeenCalled();
78
- });
79
-
80
55
  it("adds after functions in order of needed execution", function() {
81
56
  var env = new j$.Env(),
82
57
  suite = new j$.Suite({
@@ -92,251 +67,79 @@ describe("Suite", function() {
92
67
  expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
93
68
  });
94
69
 
95
- it("runs afterAll functions in order of needed execution", function() {
96
- var env = new j$.Env(),
97
- fakeQueueRunner = jasmine.createSpy('fake queue runner'),
98
- suite = new j$.Suite({
99
- env: env,
100
- description: "I am a suite",
101
- queueRunner: fakeQueueRunner
102
- }),
103
- firstAfter = jasmine.createSpy('outerAfterAll'),
104
- lastAfter = jasmine.createSpy('insideAfterAll'),
105
- fakeIt = {execute: jasmine.createSpy('it'), isExecutable: function() { return true; } };
106
-
107
- suite.afterAll(firstAfter);
108
- suite.afterAll(lastAfter);
109
- suite.addChild(fakeIt);
110
-
111
- suite.execute();
112
- var suiteFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
70
+ it('has a status of failed if any afterAll expectations have failed', function() {
71
+ var suite = new j$.Suite({
72
+ expectationResultFactory: function() { return 'hi'; }
73
+ });
74
+ suite.addChild({ result: { status: 'done' } });
113
75
 
114
- suiteFns[1]();
115
- expect(firstAfter).toHaveBeenCalled();
116
- suiteFns[2]();
117
- expect(lastAfter).toHaveBeenCalled();
76
+ suite.addExpectationResult(false);
77
+ expect(suite.status()).toBe('failed');
118
78
  });
119
79
 
120
- it("does not run *All functions if runnables are explicitly set", function(){
121
- var env = new j$.Env(),
122
- fakeQueueRunner = jasmine.createSpy('fake queue runner'),
123
- suite = new j$.Suite({
124
- env: env,
125
- description: "I am a suite",
126
- queueRunner: fakeQueueRunner,
127
- runnablesExplictlySetGetter: function(){return true;}
128
- }),
129
- beforeAll = jasmine.createSpy('beforeAll'),
130
- afterAll = jasmine.createSpy('afterAll'),
131
- fakeIt = {execute: jasmine.createSpy('it'), isExecutable: function() { return true; } };
132
-
133
- suite.beforeAll(beforeAll);
134
- suite.afterAll(afterAll);
135
- suite.addChild(fakeIt);
136
-
137
- suite.execute();
138
- var suiteFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
80
+ it("retrieves a result with updated status", function() {
81
+ var suite = new j$.Suite({});
139
82
 
140
- expect(suite.isExecutable()).toBeFalsy();
141
- expect(suiteFns.length).toEqual(1);
142
- expect(beforeAll).not.toHaveBeenCalled();
143
- expect(afterAll).not.toHaveBeenCalled();
83
+ expect(suite.getResult().status).toBe('finished');
144
84
  });
145
85
 
146
- it("can be disabled, but still calls callbacks", function() {
147
- var env = new j$.Env(),
148
- fakeQueueRunner = jasmine.createSpy('fake queue runner'),
149
- onStart = jasmine.createSpy('onStart'),
150
- resultCallback = jasmine.createSpy('resultCallback'),
151
- onComplete = jasmine.createSpy('onComplete'),
152
- suite = new j$.Suite({
153
- env: env,
154
- description: "with a child suite",
155
- onStart: onStart,
156
- resultCallback: resultCallback,
157
- queueRunner: fakeQueueRunner
158
- });
159
-
86
+ it("retrieves a result with disabled status", function() {
87
+ var suite = new j$.Suite({});
160
88
  suite.disable();
161
89
 
162
- expect(suite.disabled).toBe(true);
163
-
164
- suite.execute(onComplete);
165
-
166
- expect(fakeQueueRunner).not.toHaveBeenCalled();
167
- expect(onStart).toHaveBeenCalled();
168
- expect(resultCallback).toHaveBeenCalled();
169
- expect(onComplete).toHaveBeenCalled();
170
- });
171
-
172
- it("delegates execution of its specs, suites, beforeAlls, and afterAlls", function() {
173
- var env = new j$.Env(),
174
- parentSuiteDone = jasmine.createSpy('parent suite done'),
175
- fakeQueueRunnerForParent = jasmine.createSpy('fake parent queue runner'),
176
- parentSuite = new j$.Suite({
177
- env: env,
178
- description: "I am a parent suite",
179
- queueRunner: fakeQueueRunnerForParent
180
- }),
181
- fakeQueueRunner = jasmine.createSpy('fake queue runner'),
182
- suite = new j$.Suite({
183
- env: env,
184
- description: "with a child suite",
185
- queueRunner: fakeQueueRunner
186
- }),
187
- fakeSpec1 = {
188
- execute: jasmine.createSpy('fakeSpec1'),
189
- isExecutable: function() { return true; }
190
- },
191
- beforeAllFn = { fn: jasmine.createSpy('beforeAll') },
192
- afterAllFn = { fn: jasmine.createSpy('afterAll') };
193
-
194
- spyOn(suite, "execute");
195
-
196
- parentSuite.addChild(fakeSpec1);
197
- parentSuite.addChild(suite);
198
- parentSuite.beforeAll(beforeAllFn);
199
- parentSuite.afterAll(afterAllFn);
200
-
201
- parentSuite.execute(parentSuiteDone);
202
-
203
- var parentSuiteFns = fakeQueueRunnerForParent.calls.mostRecent().args[0].queueableFns;
204
-
205
- parentSuiteFns[0].fn();
206
- expect(beforeAllFn.fn).toHaveBeenCalled();
207
- parentSuiteFns[1].fn();
208
- expect(fakeSpec1.execute).toHaveBeenCalled();
209
- parentSuiteFns[2].fn();
210
- expect(suite.execute).toHaveBeenCalled();
211
- parentSuiteFns[3].fn();
212
- expect(afterAllFn.fn).toHaveBeenCalled();
213
- });
214
-
215
- it("does not run beforeAll or afterAll if there are no executable child specs", function() {
216
- var env = new j$.Env(),
217
- fakeQueueRunnerForParent = jasmine.createSpy('fake parent queue runner'),
218
- fakeQueueRunnerForChild = jasmine.createSpy('fake child queue runner'),
219
- parentSuite = new j$.Suite({
220
- env: env,
221
- description: "I am a suite",
222
- queueRunner: fakeQueueRunnerForParent
223
- }),
224
- childSuite = new j$.Suite({
225
- env: env,
226
- description: "I am a suite",
227
- queueRunner: fakeQueueRunnerForChild,
228
- parentSuite: parentSuite
229
- }),
230
- beforeAllFn = jasmine.createSpy('beforeAll'),
231
- afterAllFn = jasmine.createSpy('afterAll');
232
-
233
- parentSuite.addChild(childSuite);
234
- parentSuite.beforeAll(beforeAllFn);
235
- parentSuite.afterAll(afterAllFn);
236
-
237
- parentSuite.execute();
238
- expect(fakeQueueRunnerForParent).toHaveBeenCalledWith(jasmine.objectContaining({
239
- queueableFns: [{ fn: jasmine.any(Function) }]
240
- }));
90
+ expect(suite.getResult().status).toBe('disabled');
241
91
  });
242
92
 
243
- it("calls a provided onStart callback when starting", function() {
244
- var env = new j$.Env(),
245
- suiteStarted = jasmine.createSpy('suiteStarted'),
246
- fakeQueueRunner = function(attrs) { attrs.onComplete(); },
247
- suite = new j$.Suite({
248
- env: env,
249
- description: "with a child suite",
250
- onStart: suiteStarted,
251
- queueRunner: fakeQueueRunner
252
- }),
253
- fakeSpec1 = {
254
- execute: jasmine.createSpy('fakeSpec1'),
255
- isExecutable: function() { return true; }
256
- };
93
+ it("is executable if not disabled", function() {
94
+ var suite = new j$.Suite({});
257
95
 
258
- suite.execute();
259
-
260
- expect(suiteStarted).toHaveBeenCalledWith(suite);
96
+ expect(suite.isExecutable()).toBe(true);
261
97
  });
262
98
 
263
- it("calls a provided onComplete callback when done", function() {
264
- var env = new j$.Env(),
265
- suiteCompleted = jasmine.createSpy('parent suite done'),
266
- fakeQueueRunner = function(attrs) { attrs.onComplete(); },
267
- suite = new j$.Suite({
268
- env: env,
269
- description: "with a child suite",
270
- queueRunner: fakeQueueRunner
271
- }),
272
- fakeSpec1 = {
273
- execute: jasmine.createSpy('fakeSpec1')
274
- };
275
-
276
- suite.execute(suiteCompleted);
99
+ it("is not executable if disabled", function() {
100
+ var suite = new j$.Suite({});
101
+ suite.disable();
277
102
 
278
- expect(suiteCompleted).toHaveBeenCalled();
103
+ expect(suite.isExecutable()).toBe(false);
279
104
  });
280
105
 
281
- it("calls a provided result callback when done", function() {
282
- var env = new j$.Env(),
283
- suiteResultsCallback = jasmine.createSpy('suite result callback'),
284
- fakeQueueRunner = function(attrs) { attrs.onComplete(); },
285
- suite = new j$.Suite({
286
- env: env,
287
- description: "with a child suite",
288
- queueRunner: fakeQueueRunner,
289
- resultCallback: suiteResultsCallback
290
- }),
291
- fakeSpec1 = {
292
- execute: jasmine.createSpy('fakeSpec1')
293
- };
294
-
295
- suite.execute();
296
-
297
- expect(suiteResultsCallback).toHaveBeenCalledWith({
298
- id: suite.id,
299
- status: 'finished',
300
- description: "with a child suite",
301
- fullName: "with a child suite",
302
- failedExpectations: []
303
- });
304
- });
106
+ it("tells all children about expectation failures, even if one throws", function() {
107
+ var suite = new j$.Suite({}),
108
+ child1 = { addExpectationResult: jasmine.createSpy('child1#expectationResult'), result: {} },
109
+ child2 = { addExpectationResult: jasmine.createSpy('child2#expectationResult'), result: {} };
305
110
 
306
- it("calls a provided result callback with status being disabled when disabled and done", function() {
307
- var env = new j$.Env(),
308
- suiteResultsCallback = jasmine.createSpy('suite result callback'),
309
- fakeQueueRunner = function(attrs) { attrs.onComplete(); },
310
- suite = new j$.Suite({
311
- env: env,
312
- description: "with a child suite",
313
- queueRunner: fakeQueueRunner,
314
- resultCallback: suiteResultsCallback
315
- }),
316
- fakeSpec1 = {
317
- execute: jasmine.createSpy('fakeSpec1')
318
- };
111
+ suite.addChild(child1);
112
+ suite.addChild(child2);
319
113
 
320
- suite.disable();
114
+ child1.addExpectationResult.and.throwError('foo');
321
115
 
322
- suite.execute();
116
+ suite.addExpectationResult('stuff');
323
117
 
324
- expect(suiteResultsCallback).toHaveBeenCalledWith({
325
- id: suite.id,
326
- status: 'disabled',
327
- description: "with a child suite",
328
- fullName: "with a child suite",
329
- failedExpectations: []
330
- });
118
+ expect(child1.addExpectationResult).toHaveBeenCalledWith('stuff');
119
+ expect(child2.addExpectationResult).toHaveBeenCalledWith('stuff');
331
120
  });
332
121
 
333
- it('has a status of failed if any afterAll expectations have failed', function() {
122
+ it("throws an ExpectationFailed when receiving a failed expectation in an afterAll when throwOnExpectationFailure is set", function() {
334
123
  var suite = new j$.Suite({
335
- expectationResultFactory: function() { return 'hi'; }
124
+ expectationResultFactory: function(data) { return data; },
125
+ throwOnExpectationFailure: true
336
126
  });
337
127
  suite.addChild({ result: { status: 'done' } });
338
128
 
339
- suite.addExpectationResult(false);
129
+ expect(function() {
130
+ suite.addExpectationResult(false, 'failed');
131
+ }).toThrowError(j$.errors.ExpectationFailed);
132
+
340
133
  expect(suite.status()).toBe('failed');
134
+ expect(suite.result.failedExpectations).toEqual(['failed']);
341
135
  });
136
+
137
+ it("does not add an additional failure when an expectation fails in an afterAll", function(){
138
+ var suite = new j$.Suite({});
139
+ suite.addChild({ result: { status: 'done' } });
140
+
141
+ suite.onException(new j$.errors.ExpectationFailed());
142
+
143
+ expect(suite.getResult().failedExpectations).toEqual([]);
144
+ })
342
145
  });