jasmine-core 3.8.0 → 3.10.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.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot/boot.js +4 -0
- data/lib/jasmine-core/boot/boot0.js +42 -0
- data/lib/jasmine-core/boot/boot1.js +111 -0
- data/lib/jasmine-core/boot.js +4 -0
- data/lib/jasmine-core/boot0.js +64 -0
- data/lib/jasmine-core/boot1.js +133 -0
- data/lib/jasmine-core/core.py +6 -1
- data/lib/jasmine-core/jasmine-html.js +7 -4
- data/lib/jasmine-core/jasmine.js +499 -145
- data/lib/jasmine-core/version.rb +1 -1
- data/lib/jasmine-core.js +3 -2
- data/lib/jasmine-core.rb +26 -1
- metadata +17 -4
data/lib/jasmine-core/jasmine.js
CHANGED
|
@@ -96,6 +96,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
|
|
96
96
|
j$.SpyRegistry = jRequire.SpyRegistry(j$);
|
|
97
97
|
j$.SpyStrategy = jRequire.SpyStrategy(j$);
|
|
98
98
|
j$.StringMatching = jRequire.StringMatching(j$);
|
|
99
|
+
j$.StringContaining = jRequire.StringContaining(j$);
|
|
99
100
|
j$.UserContext = jRequire.UserContext(j$);
|
|
100
101
|
j$.Suite = jRequire.Suite(j$);
|
|
101
102
|
j$.Timer = jRequire.Timer();
|
|
@@ -175,6 +176,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
175
176
|
* Maximum object depth the pretty printer will print to.
|
|
176
177
|
* Set this to a lower value to speed up pretty printing if you have large objects.
|
|
177
178
|
* @name jasmine.MAX_PRETTY_PRINT_DEPTH
|
|
179
|
+
* @default 8
|
|
178
180
|
* @since 1.3.0
|
|
179
181
|
*/
|
|
180
182
|
j$.MAX_PRETTY_PRINT_DEPTH = 8;
|
|
@@ -183,6 +185,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
183
185
|
* This will also limit the number of keys and values displayed for an object.
|
|
184
186
|
* Elements past this number will be ellipised.
|
|
185
187
|
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
|
|
188
|
+
* @default 50
|
|
186
189
|
* @since 2.7.0
|
|
187
190
|
*/
|
|
188
191
|
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 50;
|
|
@@ -190,15 +193,35 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
190
193
|
* Maximum number of characters to display when pretty printing objects.
|
|
191
194
|
* Characters past this number will be ellipised.
|
|
192
195
|
* @name jasmine.MAX_PRETTY_PRINT_CHARS
|
|
196
|
+
* @default 100
|
|
193
197
|
* @since 2.9.0
|
|
194
198
|
*/
|
|
195
199
|
j$.MAX_PRETTY_PRINT_CHARS = 1000;
|
|
196
200
|
/**
|
|
197
|
-
* Default number of milliseconds Jasmine will wait for an asynchronous spec
|
|
201
|
+
* Default number of milliseconds Jasmine will wait for an asynchronous spec,
|
|
202
|
+
* before, or after function to complete. This can be overridden on a case by
|
|
203
|
+
* case basis by passing a time limit as the third argument to {@link it},
|
|
204
|
+
* {@link beforeEach}, {@link afterEach}, {@link beforeAll}, or
|
|
205
|
+
* {@link afterAll}. The value must be no greater than the largest number of
|
|
206
|
+
* milliseconds supported by setTimeout, which is usually 2147483647.
|
|
207
|
+
*
|
|
208
|
+
* While debugging tests, you may want to set this to a large number (or pass
|
|
209
|
+
* a large number to one of the functions mentioned above) so that Jasmine
|
|
210
|
+
* does not move on to after functions or the next spec while you're debugging.
|
|
198
211
|
* @name jasmine.DEFAULT_TIMEOUT_INTERVAL
|
|
212
|
+
* @default 5000
|
|
199
213
|
* @since 1.3.0
|
|
200
214
|
*/
|
|
201
|
-
|
|
215
|
+
var DEFAULT_TIMEOUT_INTERVAL = 5000;
|
|
216
|
+
Object.defineProperty(j$, 'DEFAULT_TIMEOUT_INTERVAL', {
|
|
217
|
+
get: function() {
|
|
218
|
+
return DEFAULT_TIMEOUT_INTERVAL;
|
|
219
|
+
},
|
|
220
|
+
set: function(newValue) {
|
|
221
|
+
j$.util.validateTimeout(newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL');
|
|
222
|
+
DEFAULT_TIMEOUT_INTERVAL = newValue;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
202
225
|
|
|
203
226
|
j$.getGlobal = function() {
|
|
204
227
|
return jasmineGlobal;
|
|
@@ -267,9 +290,21 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
267
290
|
};
|
|
268
291
|
|
|
269
292
|
j$.isError_ = function(value) {
|
|
293
|
+
if (!value) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
|
|
270
297
|
if (value instanceof Error) {
|
|
271
298
|
return true;
|
|
272
299
|
}
|
|
300
|
+
if (
|
|
301
|
+
typeof window !== 'undefined' &&
|
|
302
|
+
typeof window.trustedTypes !== 'undefined'
|
|
303
|
+
) {
|
|
304
|
+
return (
|
|
305
|
+
typeof value.stack === 'string' && typeof value.message === 'string'
|
|
306
|
+
);
|
|
307
|
+
}
|
|
273
308
|
if (value && value.constructor && value.constructor.constructor) {
|
|
274
309
|
var valueGlobal = value.constructor.constructor('return this');
|
|
275
310
|
if (j$.isFunction_(valueGlobal)) {
|
|
@@ -385,7 +420,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
385
420
|
};
|
|
386
421
|
|
|
387
422
|
/**
|
|
388
|
-
* Get
|
|
423
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
389
424
|
* that will succeed if the actual value being compared is an instance of the specified class/constructor.
|
|
390
425
|
* @name jasmine.any
|
|
391
426
|
* @since 1.3.0
|
|
@@ -397,7 +432,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
397
432
|
};
|
|
398
433
|
|
|
399
434
|
/**
|
|
400
|
-
* Get
|
|
435
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
401
436
|
* that will succeed if the actual value being compared is not `null` and not `undefined`.
|
|
402
437
|
* @name jasmine.anything
|
|
403
438
|
* @since 2.2.0
|
|
@@ -408,7 +443,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
408
443
|
};
|
|
409
444
|
|
|
410
445
|
/**
|
|
411
|
-
* Get
|
|
446
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
412
447
|
* that will succeed if the actual value being compared is `true` or anything truthy.
|
|
413
448
|
* @name jasmine.truthy
|
|
414
449
|
* @since 3.1.0
|
|
@@ -419,7 +454,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
419
454
|
};
|
|
420
455
|
|
|
421
456
|
/**
|
|
422
|
-
* Get
|
|
457
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
423
458
|
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
|
424
459
|
* @name jasmine.falsy
|
|
425
460
|
* @since 3.1.0
|
|
@@ -430,7 +465,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
430
465
|
};
|
|
431
466
|
|
|
432
467
|
/**
|
|
433
|
-
* Get
|
|
468
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
434
469
|
* that will succeed if the actual value being compared is empty.
|
|
435
470
|
* @name jasmine.empty
|
|
436
471
|
* @since 3.1.0
|
|
@@ -441,7 +476,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
441
476
|
};
|
|
442
477
|
|
|
443
478
|
/**
|
|
444
|
-
* Get
|
|
479
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
445
480
|
* that will succeed if the actual value being compared is not empty.
|
|
446
481
|
* @name jasmine.notEmpty
|
|
447
482
|
* @since 3.1.0
|
|
@@ -452,7 +487,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
452
487
|
};
|
|
453
488
|
|
|
454
489
|
/**
|
|
455
|
-
* Get
|
|
490
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
456
491
|
* that will succeed if the actual value being compared contains at least the keys and values.
|
|
457
492
|
* @name jasmine.objectContaining
|
|
458
493
|
* @since 1.3.0
|
|
@@ -464,7 +499,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
464
499
|
};
|
|
465
500
|
|
|
466
501
|
/**
|
|
467
|
-
* Get
|
|
502
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
468
503
|
* that will succeed if the actual value is a `String` that matches the `RegExp` or `String`.
|
|
469
504
|
* @name jasmine.stringMatching
|
|
470
505
|
* @since 2.2.0
|
|
@@ -476,7 +511,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
476
511
|
};
|
|
477
512
|
|
|
478
513
|
/**
|
|
479
|
-
* Get
|
|
514
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
515
|
+
* that will succeed if the actual value is a `String` that contains the specified `String`.
|
|
516
|
+
* @name jasmine.stringContaining
|
|
517
|
+
* @since 3.10.0
|
|
518
|
+
* @function
|
|
519
|
+
* @param {String} expected
|
|
520
|
+
*/
|
|
521
|
+
j$.stringContaining = function(expected) {
|
|
522
|
+
return new j$.StringContaining(expected);
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
480
527
|
* that will succeed if the actual value is an `Array` that contains at least the elements in the sample.
|
|
481
528
|
* @name jasmine.arrayContaining
|
|
482
529
|
* @since 2.2.0
|
|
@@ -488,7 +535,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
488
535
|
};
|
|
489
536
|
|
|
490
537
|
/**
|
|
491
|
-
* Get
|
|
538
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
492
539
|
* that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
|
|
493
540
|
* @name jasmine.arrayWithExactContents
|
|
494
541
|
* @since 2.8.0
|
|
@@ -500,7 +547,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
500
547
|
};
|
|
501
548
|
|
|
502
549
|
/**
|
|
503
|
-
* Get
|
|
550
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
504
551
|
* that will succeed if every key/value pair in the sample passes the deep equality comparison
|
|
505
552
|
* with at least one key/value pair in the actual value being compared
|
|
506
553
|
* @name jasmine.mapContaining
|
|
@@ -513,7 +560,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
|
513
560
|
};
|
|
514
561
|
|
|
515
562
|
/**
|
|
516
|
-
* Get
|
|
563
|
+
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
|
517
564
|
* that will succeed if every item in the sample passes the deep equality comparison
|
|
518
565
|
* with at least one item in the actual value being compared
|
|
519
566
|
* @name jasmine.setContaining
|
|
@@ -688,6 +735,21 @@ getJasmineRequireObj().util = function(j$) {
|
|
|
688
735
|
}
|
|
689
736
|
};
|
|
690
737
|
|
|
738
|
+
util.validateTimeout = function(timeout, msgPrefix) {
|
|
739
|
+
// Timeouts are implemented with setTimeout, which only supports a limited
|
|
740
|
+
// range of values. The limit is unspecified, as is the behavior when it's
|
|
741
|
+
// exceeded. But on all currently supported JS runtimes, setTimeout calls
|
|
742
|
+
// the callback immediately when the timeout is greater than 2147483647
|
|
743
|
+
// (the maximum value of a signed 32 bit integer).
|
|
744
|
+
var max = 2147483647;
|
|
745
|
+
|
|
746
|
+
if (timeout > max) {
|
|
747
|
+
throw new Error(
|
|
748
|
+
(msgPrefix || 'Timeout value') + ' cannot be greater than ' + max
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
|
|
691
753
|
return util;
|
|
692
754
|
};
|
|
693
755
|
|
|
@@ -695,17 +757,26 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
695
757
|
/**
|
|
696
758
|
* @interface Spec
|
|
697
759
|
* @see Configuration#specFilter
|
|
760
|
+
* @since 2.0.0
|
|
698
761
|
*/
|
|
699
762
|
function Spec(attrs) {
|
|
700
763
|
this.expectationFactory = attrs.expectationFactory;
|
|
701
764
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
|
702
765
|
this.resultCallback = attrs.resultCallback || function() {};
|
|
766
|
+
/**
|
|
767
|
+
* The unique ID of this spec.
|
|
768
|
+
* @name Spec#id
|
|
769
|
+
* @readonly
|
|
770
|
+
* @type {string}
|
|
771
|
+
* @since 2.0.0
|
|
772
|
+
*/
|
|
703
773
|
this.id = attrs.id;
|
|
704
774
|
/**
|
|
705
775
|
* The description passed to the {@link it} that created this spec.
|
|
706
776
|
* @name Spec#description
|
|
707
777
|
* @readonly
|
|
708
778
|
* @type {string}
|
|
779
|
+
* @since 2.0.0
|
|
709
780
|
*/
|
|
710
781
|
this.description = attrs.description || '';
|
|
711
782
|
this.queueableFn = attrs.queueableFn;
|
|
@@ -720,6 +791,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
720
791
|
return {};
|
|
721
792
|
};
|
|
722
793
|
this.onStart = attrs.onStart || function() {};
|
|
794
|
+
this.autoCleanClosures =
|
|
795
|
+
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
|
723
796
|
this.getSpecName =
|
|
724
797
|
attrs.getSpecName ||
|
|
725
798
|
function() {
|
|
@@ -737,7 +810,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
737
810
|
this.timer = attrs.timer || new j$.Timer();
|
|
738
811
|
|
|
739
812
|
if (!this.queueableFn.fn) {
|
|
740
|
-
this.
|
|
813
|
+
this.exclude();
|
|
741
814
|
}
|
|
742
815
|
|
|
743
816
|
/**
|
|
@@ -752,7 +825,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
752
825
|
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
|
753
826
|
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
|
754
827
|
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
|
755
|
-
|
|
828
|
+
* @since 2.0.0
|
|
829
|
+
x */
|
|
756
830
|
this.result = {
|
|
757
831
|
id: this.id,
|
|
758
832
|
description: this.description,
|
|
@@ -804,7 +878,9 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
804
878
|
|
|
805
879
|
var complete = {
|
|
806
880
|
fn: function(done) {
|
|
807
|
-
self.
|
|
881
|
+
if (self.autoCleanClosures) {
|
|
882
|
+
self.queueableFn.fn = null;
|
|
883
|
+
}
|
|
808
884
|
self.result.status = self.status(excluded, failSpecWithNoExp);
|
|
809
885
|
self.result.duration = self.timer.elapsed();
|
|
810
886
|
self.resultCallback(self.result, done);
|
|
@@ -841,6 +917,36 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
841
917
|
this.queueRunnerFactory(runnerConfig);
|
|
842
918
|
};
|
|
843
919
|
|
|
920
|
+
Spec.prototype.reset = function() {
|
|
921
|
+
/**
|
|
922
|
+
* @typedef SpecResult
|
|
923
|
+
* @property {Int} id - The unique id of this spec.
|
|
924
|
+
* @property {String} description - The description passed to the {@link it} that created this spec.
|
|
925
|
+
* @property {String} fullName - The full description including all ancestors of this spec.
|
|
926
|
+
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
|
927
|
+
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
|
928
|
+
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
|
929
|
+
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
|
930
|
+
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
|
931
|
+
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
|
932
|
+
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
|
933
|
+
* @since 2.0.0
|
|
934
|
+
*/
|
|
935
|
+
this.result = {
|
|
936
|
+
id: this.id,
|
|
937
|
+
description: this.description,
|
|
938
|
+
fullName: this.getFullName(),
|
|
939
|
+
failedExpectations: [],
|
|
940
|
+
passedExpectations: [],
|
|
941
|
+
deprecationWarnings: [],
|
|
942
|
+
pendingReason: this.excludeMessage,
|
|
943
|
+
duration: null,
|
|
944
|
+
properties: null,
|
|
945
|
+
trace: null
|
|
946
|
+
};
|
|
947
|
+
this.markedPending = this.markedExcluding;
|
|
948
|
+
};
|
|
949
|
+
|
|
844
950
|
Spec.prototype.onException = function onException(e) {
|
|
845
951
|
if (Spec.isPendingSpecException(e)) {
|
|
846
952
|
this.pend(extractCustomPendingMessage(e));
|
|
@@ -864,6 +970,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
864
970
|
);
|
|
865
971
|
};
|
|
866
972
|
|
|
973
|
+
/*
|
|
974
|
+
* Marks state as pending
|
|
975
|
+
* @param {string} [message] An optional reason message
|
|
976
|
+
*/
|
|
867
977
|
Spec.prototype.pend = function(message) {
|
|
868
978
|
this.markedPending = true;
|
|
869
979
|
if (message) {
|
|
@@ -871,6 +981,19 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
871
981
|
}
|
|
872
982
|
};
|
|
873
983
|
|
|
984
|
+
/*
|
|
985
|
+
* Like {@link Spec#pend}, but pending state will survive {@link Spec#reset}
|
|
986
|
+
* Useful for fit, xit, where pending state remains.
|
|
987
|
+
* @param {string} [message] An optional reason message
|
|
988
|
+
*/
|
|
989
|
+
Spec.prototype.exclude = function(message) {
|
|
990
|
+
this.markedExcluding = true;
|
|
991
|
+
if (this.message) {
|
|
992
|
+
this.excludeMessage = message;
|
|
993
|
+
}
|
|
994
|
+
this.pend();
|
|
995
|
+
};
|
|
996
|
+
|
|
874
997
|
Spec.prototype.getResult = function() {
|
|
875
998
|
this.result.status = this.status();
|
|
876
999
|
return this.result;
|
|
@@ -903,6 +1026,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
903
1026
|
* @name Spec#getFullName
|
|
904
1027
|
* @function
|
|
905
1028
|
* @returns {string}
|
|
1029
|
+
* @since 2.0.0
|
|
906
1030
|
*/
|
|
907
1031
|
Spec.prototype.getFullName = function() {
|
|
908
1032
|
return this.getSpecName(this);
|
|
@@ -1057,8 +1181,17 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1057
1181
|
* @since 3.3.0
|
|
1058
1182
|
* @type Boolean
|
|
1059
1183
|
* @default false
|
|
1184
|
+
* @deprecated Use the `stopOnSpecFailure` config property instead.
|
|
1060
1185
|
*/
|
|
1061
1186
|
failFast: false,
|
|
1187
|
+
/**
|
|
1188
|
+
* Whether to stop execution of the suite after the first spec failure
|
|
1189
|
+
* @name Configuration#stopOnSpecFailure
|
|
1190
|
+
* @since 3.9.0
|
|
1191
|
+
* @type Boolean
|
|
1192
|
+
* @default false
|
|
1193
|
+
*/
|
|
1194
|
+
stopOnSpecFailure: false,
|
|
1062
1195
|
/**
|
|
1063
1196
|
* Whether to fail the spec if it ran no expectations. By default
|
|
1064
1197
|
* a spec that ran no expectations is reported as passed. Setting this
|
|
@@ -1075,8 +1208,17 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1075
1208
|
* @since 3.3.0
|
|
1076
1209
|
* @type Boolean
|
|
1077
1210
|
* @default false
|
|
1211
|
+
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
|
|
1078
1212
|
*/
|
|
1079
1213
|
oneFailurePerSpec: false,
|
|
1214
|
+
/**
|
|
1215
|
+
* Whether to cause specs to only have one expectation failure.
|
|
1216
|
+
* @name Configuration#stopSpecOnExpectationFailure
|
|
1217
|
+
* @since 3.3.0
|
|
1218
|
+
* @type Boolean
|
|
1219
|
+
* @default false
|
|
1220
|
+
*/
|
|
1221
|
+
stopSpecOnExpectationFailure: false,
|
|
1080
1222
|
/**
|
|
1081
1223
|
* A function that takes a spec and returns true if it should be executed
|
|
1082
1224
|
* or false if it should be skipped.
|
|
@@ -1112,7 +1254,16 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1112
1254
|
* @type function
|
|
1113
1255
|
* @default undefined
|
|
1114
1256
|
*/
|
|
1115
|
-
Promise: undefined
|
|
1257
|
+
Promise: undefined,
|
|
1258
|
+
/**
|
|
1259
|
+
* Clean closures when a suite is done running (done by clearing the stored function reference).
|
|
1260
|
+
* This prevents memory leaks, but you won't be able to run jasmine multiple times.
|
|
1261
|
+
* @name Configuration#autoCleanClosures
|
|
1262
|
+
* @since 3.10.0
|
|
1263
|
+
* @type boolean
|
|
1264
|
+
* @default true
|
|
1265
|
+
*/
|
|
1266
|
+
autoCleanClosures: true
|
|
1116
1267
|
};
|
|
1117
1268
|
|
|
1118
1269
|
var currentSuite = function() {
|
|
@@ -1162,33 +1313,65 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1162
1313
|
* @function
|
|
1163
1314
|
*/
|
|
1164
1315
|
this.configure = function(configuration) {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1316
|
+
var booleanProps = [
|
|
1317
|
+
'random',
|
|
1318
|
+
'failSpecWithNoExpectations',
|
|
1319
|
+
'hideDisabled',
|
|
1320
|
+
'autoCleanClosures'
|
|
1321
|
+
];
|
|
1322
|
+
|
|
1323
|
+
booleanProps.forEach(function(prop) {
|
|
1324
|
+
if (typeof configuration[prop] !== 'undefined') {
|
|
1325
|
+
config[prop] = !!configuration[prop];
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1172
1328
|
|
|
1173
|
-
if (configuration.
|
|
1174
|
-
|
|
1175
|
-
|
|
1329
|
+
if (typeof configuration.failFast !== 'undefined') {
|
|
1330
|
+
if (typeof configuration.stopOnSpecFailure !== 'undefined') {
|
|
1331
|
+
if (configuration.stopOnSpecFailure !== configuration.failFast) {
|
|
1332
|
+
throw new Error(
|
|
1333
|
+
'stopOnSpecFailure and failFast are aliases for ' +
|
|
1334
|
+
"each other. Don't set failFast if you also set stopOnSpecFailure."
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1176
1338
|
|
|
1177
|
-
if (configuration.hasOwnProperty('failFast')) {
|
|
1178
1339
|
config.failFast = configuration.failFast;
|
|
1340
|
+
config.stopOnSpecFailure = configuration.failFast;
|
|
1341
|
+
} else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
|
|
1342
|
+
config.failFast = configuration.stopOnSpecFailure;
|
|
1343
|
+
config.stopOnSpecFailure = configuration.stopOnSpecFailure;
|
|
1179
1344
|
}
|
|
1180
1345
|
|
|
1181
|
-
if (configuration.
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1346
|
+
if (typeof configuration.oneFailurePerSpec !== 'undefined') {
|
|
1347
|
+
if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
|
|
1348
|
+
if (
|
|
1349
|
+
configuration.stopSpecOnExpectationFailure !==
|
|
1350
|
+
configuration.oneFailurePerSpec
|
|
1351
|
+
) {
|
|
1352
|
+
throw new Error(
|
|
1353
|
+
'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
|
|
1354
|
+
"each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1185
1358
|
|
|
1186
|
-
if (configuration.hasOwnProperty('oneFailurePerSpec')) {
|
|
1187
1359
|
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
|
|
1360
|
+
config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
|
|
1361
|
+
} else if (
|
|
1362
|
+
typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
|
|
1363
|
+
) {
|
|
1364
|
+
config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
|
|
1365
|
+
config.stopSpecOnExpectationFailure =
|
|
1366
|
+
configuration.stopSpecOnExpectationFailure;
|
|
1188
1367
|
}
|
|
1189
1368
|
|
|
1190
|
-
if (configuration.
|
|
1191
|
-
config.
|
|
1369
|
+
if (configuration.specFilter) {
|
|
1370
|
+
config.specFilter = configuration.specFilter;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
if (typeof configuration.seed !== 'undefined') {
|
|
1374
|
+
config.seed = configuration.seed;
|
|
1192
1375
|
}
|
|
1193
1376
|
|
|
1194
1377
|
// Don't use hasOwnProperty to check for Promise existence because Promise
|
|
@@ -1375,7 +1558,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1375
1558
|
}
|
|
1376
1559
|
|
|
1377
1560
|
delayedExpectationResult.message +=
|
|
1378
|
-
'Did you forget to return or await the result of expectAsync
|
|
1561
|
+
'1. Did you forget to return or await the result of expectAsync?\n' +
|
|
1562
|
+
'2. Was done() invoked before an async operation completed?\n' +
|
|
1563
|
+
'3. Did an expectation follow a call to done()?';
|
|
1379
1564
|
|
|
1380
1565
|
topSuite.result.failedExpectations.push(delayedExpectationResult);
|
|
1381
1566
|
}
|
|
@@ -1440,10 +1625,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1440
1625
|
delete runnableResources[id];
|
|
1441
1626
|
};
|
|
1442
1627
|
|
|
1443
|
-
var beforeAndAfterFns = function(
|
|
1628
|
+
var beforeAndAfterFns = function(targetSuite) {
|
|
1444
1629
|
return function() {
|
|
1445
1630
|
var befores = [],
|
|
1446
|
-
afters = []
|
|
1631
|
+
afters = [],
|
|
1632
|
+
suite = targetSuite;
|
|
1447
1633
|
|
|
1448
1634
|
while (suite) {
|
|
1449
1635
|
befores = befores.concat(suite.beforeFns);
|
|
@@ -1486,18 +1672,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1486
1672
|
* @since 2.3.0
|
|
1487
1673
|
* @function
|
|
1488
1674
|
* @param {Boolean} value Whether to throw when a expectation fails
|
|
1489
|
-
* @deprecated Use the `
|
|
1675
|
+
* @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
|
|
1490
1676
|
*/
|
|
1491
1677
|
this.throwOnExpectationFailure = function(value) {
|
|
1492
1678
|
this.deprecated(
|
|
1493
|
-
'Setting throwOnExpectationFailure directly on Env is deprecated and
|
|
1679
|
+
'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
|
|
1680
|
+
'will be removed in a future version of Jasmine. Please use the ' +
|
|
1681
|
+
'stopSpecOnExpectationFailure option in `configure`.'
|
|
1494
1682
|
);
|
|
1495
1683
|
this.configure({ oneFailurePerSpec: !!value });
|
|
1496
1684
|
};
|
|
1497
1685
|
|
|
1498
1686
|
this.throwingExpectationFailures = function() {
|
|
1499
1687
|
this.deprecated(
|
|
1500
|
-
'Getting throwingExpectationFailures directly from Env is deprecated
|
|
1688
|
+
'Getting throwingExpectationFailures directly from Env is deprecated ' +
|
|
1689
|
+
'and will be removed in a future version of Jasmine. Please check ' +
|
|
1690
|
+
'the stopSpecOnExpectationFailure option from `configuration`.'
|
|
1501
1691
|
);
|
|
1502
1692
|
return config.oneFailurePerSpec;
|
|
1503
1693
|
};
|
|
@@ -1508,18 +1698,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1508
1698
|
* @since 2.7.0
|
|
1509
1699
|
* @function
|
|
1510
1700
|
* @param {Boolean} value Whether to stop suite execution when a spec fails
|
|
1511
|
-
* @deprecated Use the `
|
|
1701
|
+
* @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
|
|
1512
1702
|
*/
|
|
1513
1703
|
this.stopOnSpecFailure = function(value) {
|
|
1514
1704
|
this.deprecated(
|
|
1515
|
-
'Setting stopOnSpecFailure directly is deprecated and will be
|
|
1705
|
+
'Setting stopOnSpecFailure directly is deprecated and will be ' +
|
|
1706
|
+
'removed in a future version of Jasmine. Please use the ' +
|
|
1707
|
+
'stopOnSpecFailure option in `configure`.'
|
|
1516
1708
|
);
|
|
1517
|
-
this.configure({
|
|
1709
|
+
this.configure({ stopOnSpecFailure: !!value });
|
|
1518
1710
|
};
|
|
1519
1711
|
|
|
1520
1712
|
this.stoppingOnSpecFailure = function() {
|
|
1521
1713
|
this.deprecated(
|
|
1522
|
-
'Getting stoppingOnSpecFailure directly from Env is deprecated and
|
|
1714
|
+
'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
|
|
1715
|
+
'will be removed in a future version of Jasmine. Please check the ' +
|
|
1716
|
+
'stopOnSpecFailure option from `configuration`.'
|
|
1523
1717
|
);
|
|
1524
1718
|
return config.failFast;
|
|
1525
1719
|
};
|
|
@@ -1575,6 +1769,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1575
1769
|
* @name Env#hideDisabled
|
|
1576
1770
|
* @since 3.2.0
|
|
1577
1771
|
* @function
|
|
1772
|
+
* @deprecated Use the `hideDisabled` option with {@link Env#configure}
|
|
1578
1773
|
*/
|
|
1579
1774
|
this.hideDisabled = function(value) {
|
|
1580
1775
|
this.deprecated(
|
|
@@ -1607,9 +1802,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1607
1802
|
var queueRunnerFactory = function(options, args) {
|
|
1608
1803
|
var failFast = false;
|
|
1609
1804
|
if (options.isLeaf) {
|
|
1610
|
-
failFast = config.
|
|
1805
|
+
failFast = config.stopSpecOnExpectationFailure;
|
|
1611
1806
|
} else if (!options.isReporter) {
|
|
1612
|
-
failFast = config.
|
|
1807
|
+
failFast = config.stopOnSpecFailure;
|
|
1613
1808
|
}
|
|
1614
1809
|
options.clearStack = options.clearStack || clearStack;
|
|
1615
1810
|
options.timeout = {
|
|
@@ -1635,9 +1830,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1635
1830
|
description: 'Jasmine__TopLevel__Suite',
|
|
1636
1831
|
expectationFactory: expectationFactory,
|
|
1637
1832
|
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
|
1638
|
-
expectationResultFactory: expectationResultFactory
|
|
1833
|
+
expectationResultFactory: expectationResultFactory,
|
|
1834
|
+
autoCleanClosures: config.autoCleanClosures
|
|
1639
1835
|
});
|
|
1640
|
-
defaultResourcesForRunnable(topSuite.id);
|
|
1641
1836
|
currentDeclarationSuite = topSuite;
|
|
1642
1837
|
|
|
1643
1838
|
/**
|
|
@@ -1646,6 +1841,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1646
1841
|
* @function
|
|
1647
1842
|
* @name Env#topSuite
|
|
1648
1843
|
* @return {Suite} the root suite
|
|
1844
|
+
* @since 2.0.0
|
|
1649
1845
|
*/
|
|
1650
1846
|
this.topSuite = function() {
|
|
1651
1847
|
return topSuite;
|
|
@@ -1741,13 +1937,24 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1741
1937
|
*
|
|
1742
1938
|
* execute should not be called more than once.
|
|
1743
1939
|
*
|
|
1940
|
+
* If the environment supports promises, execute will return a promise that
|
|
1941
|
+
* is resolved after the suite finishes executing. The promise will be
|
|
1942
|
+
* resolved (not rejected) as long as the suite runs to completion. Use a
|
|
1943
|
+
* {@link Reporter} to determine whether or not the suite passed.
|
|
1944
|
+
*
|
|
1744
1945
|
* @name Env#execute
|
|
1745
1946
|
* @since 2.0.0
|
|
1746
1947
|
* @function
|
|
1747
1948
|
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
|
|
1748
1949
|
* @param {Function=} onComplete Function that will be called after all specs have run
|
|
1950
|
+
* @return {Promise<undefined>}
|
|
1749
1951
|
*/
|
|
1750
1952
|
this.execute = function(runnablesToRun, onComplete) {
|
|
1953
|
+
if (this._executedBefore) {
|
|
1954
|
+
topSuite.reset();
|
|
1955
|
+
}
|
|
1956
|
+
this._executedBefore = true;
|
|
1957
|
+
defaultResourcesForRunnable(topSuite.id);
|
|
1751
1958
|
installGlobalErrors();
|
|
1752
1959
|
|
|
1753
1960
|
if (!runnablesToRun) {
|
|
@@ -1805,65 +2012,88 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1805
2012
|
var jasmineTimer = new j$.Timer();
|
|
1806
2013
|
jasmineTimer.start();
|
|
1807
2014
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
{
|
|
1816
|
-
totalSpecsDefined: totalSpecsDefined,
|
|
1817
|
-
order: order
|
|
1818
|
-
},
|
|
1819
|
-
function() {
|
|
1820
|
-
currentlyExecutingSuites.push(topSuite);
|
|
1821
|
-
|
|
1822
|
-
processor.execute(function() {
|
|
1823
|
-
clearResourcesForRunnable(topSuite.id);
|
|
1824
|
-
currentlyExecutingSuites.pop();
|
|
1825
|
-
var overallStatus, incompleteReason;
|
|
1826
|
-
|
|
1827
|
-
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
|
|
1828
|
-
overallStatus = 'failed';
|
|
1829
|
-
} else if (focusedRunnables.length > 0) {
|
|
1830
|
-
overallStatus = 'incomplete';
|
|
1831
|
-
incompleteReason = 'fit() or fdescribe() was found';
|
|
1832
|
-
} else if (totalSpecsDefined === 0) {
|
|
1833
|
-
overallStatus = 'incomplete';
|
|
1834
|
-
incompleteReason = 'No specs found';
|
|
1835
|
-
} else {
|
|
1836
|
-
overallStatus = 'passed';
|
|
2015
|
+
var Promise = customPromise || global.Promise;
|
|
2016
|
+
|
|
2017
|
+
if (Promise) {
|
|
2018
|
+
return new Promise(function(resolve) {
|
|
2019
|
+
runAll(function() {
|
|
2020
|
+
if (onComplete) {
|
|
2021
|
+
onComplete();
|
|
1837
2022
|
}
|
|
1838
2023
|
|
|
1839
|
-
|
|
1840
|
-
* Information passed to the {@link Reporter#jasmineDone} event.
|
|
1841
|
-
* @typedef JasmineDoneInfo
|
|
1842
|
-
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
|
1843
|
-
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
|
1844
|
-
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
|
1845
|
-
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
|
1846
|
-
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
|
1847
|
-
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
|
1848
|
-
*/
|
|
1849
|
-
reporter.jasmineDone(
|
|
1850
|
-
{
|
|
1851
|
-
overallStatus: overallStatus,
|
|
1852
|
-
totalTime: jasmineTimer.elapsed(),
|
|
1853
|
-
incompleteReason: incompleteReason,
|
|
1854
|
-
order: order,
|
|
1855
|
-
failedExpectations: topSuite.result.failedExpectations,
|
|
1856
|
-
deprecationWarnings: topSuite.result.deprecationWarnings
|
|
1857
|
-
},
|
|
1858
|
-
function() {
|
|
1859
|
-
if (onComplete) {
|
|
1860
|
-
onComplete();
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
);
|
|
2024
|
+
resolve();
|
|
1864
2025
|
});
|
|
1865
|
-
}
|
|
1866
|
-
|
|
2026
|
+
});
|
|
2027
|
+
} else {
|
|
2028
|
+
runAll(function() {
|
|
2029
|
+
if (onComplete) {
|
|
2030
|
+
onComplete();
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
function runAll(done) {
|
|
2036
|
+
/**
|
|
2037
|
+
* Information passed to the {@link Reporter#jasmineStarted} event.
|
|
2038
|
+
* @typedef JasmineStartedInfo
|
|
2039
|
+
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
|
|
2040
|
+
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
|
2041
|
+
* @since 2.0.0
|
|
2042
|
+
*/
|
|
2043
|
+
reporter.jasmineStarted(
|
|
2044
|
+
{
|
|
2045
|
+
totalSpecsDefined: totalSpecsDefined,
|
|
2046
|
+
order: order
|
|
2047
|
+
},
|
|
2048
|
+
function() {
|
|
2049
|
+
currentlyExecutingSuites.push(topSuite);
|
|
2050
|
+
|
|
2051
|
+
processor.execute(function() {
|
|
2052
|
+
clearResourcesForRunnable(topSuite.id);
|
|
2053
|
+
currentlyExecutingSuites.pop();
|
|
2054
|
+
var overallStatus, incompleteReason;
|
|
2055
|
+
|
|
2056
|
+
if (
|
|
2057
|
+
hasFailures ||
|
|
2058
|
+
topSuite.result.failedExpectations.length > 0
|
|
2059
|
+
) {
|
|
2060
|
+
overallStatus = 'failed';
|
|
2061
|
+
} else if (focusedRunnables.length > 0) {
|
|
2062
|
+
overallStatus = 'incomplete';
|
|
2063
|
+
incompleteReason = 'fit() or fdescribe() was found';
|
|
2064
|
+
} else if (totalSpecsDefined === 0) {
|
|
2065
|
+
overallStatus = 'incomplete';
|
|
2066
|
+
incompleteReason = 'No specs found';
|
|
2067
|
+
} else {
|
|
2068
|
+
overallStatus = 'passed';
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
/**
|
|
2072
|
+
* Information passed to the {@link Reporter#jasmineDone} event.
|
|
2073
|
+
* @typedef JasmineDoneInfo
|
|
2074
|
+
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
|
2075
|
+
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
|
2076
|
+
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
|
2077
|
+
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
|
2078
|
+
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
|
2079
|
+
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
|
2080
|
+
* @since 2.4.0
|
|
2081
|
+
*/
|
|
2082
|
+
reporter.jasmineDone(
|
|
2083
|
+
{
|
|
2084
|
+
overallStatus: overallStatus,
|
|
2085
|
+
totalTime: jasmineTimer.elapsed(),
|
|
2086
|
+
incompleteReason: incompleteReason,
|
|
2087
|
+
order: order,
|
|
2088
|
+
failedExpectations: topSuite.result.failedExpectations,
|
|
2089
|
+
deprecationWarnings: topSuite.result.deprecationWarnings
|
|
2090
|
+
},
|
|
2091
|
+
done
|
|
2092
|
+
);
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
1867
2097
|
};
|
|
1868
2098
|
|
|
1869
2099
|
/**
|
|
@@ -2011,7 +2241,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2011
2241
|
expectationFactory: expectationFactory,
|
|
2012
2242
|
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
|
2013
2243
|
expectationResultFactory: expectationResultFactory,
|
|
2014
|
-
throwOnExpectationFailure: config.oneFailurePerSpec
|
|
2244
|
+
throwOnExpectationFailure: config.oneFailurePerSpec,
|
|
2245
|
+
autoCleanClosures: config.autoCleanClosures
|
|
2015
2246
|
});
|
|
2016
2247
|
|
|
2017
2248
|
return suite;
|
|
@@ -2024,8 +2255,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2024
2255
|
if (specDefinitions.length > 0) {
|
|
2025
2256
|
throw new Error('describe does not expect any arguments');
|
|
2026
2257
|
}
|
|
2027
|
-
if (currentDeclarationSuite.
|
|
2028
|
-
suite.
|
|
2258
|
+
if (currentDeclarationSuite.markedExcluding) {
|
|
2259
|
+
suite.exclude();
|
|
2029
2260
|
}
|
|
2030
2261
|
addSpecsToSuite(suite, specDefinitions);
|
|
2031
2262
|
return suite;
|
|
@@ -2035,7 +2266,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2035
2266
|
ensureIsNotNested('xdescribe');
|
|
2036
2267
|
ensureIsFunction(specDefinitions, 'xdescribe');
|
|
2037
2268
|
var suite = suiteFactory(description);
|
|
2038
|
-
suite.
|
|
2269
|
+
suite.exclude();
|
|
2039
2270
|
addSpecsToSuite(suite, specDefinitions);
|
|
2040
2271
|
return suite;
|
|
2041
2272
|
};
|
|
@@ -2120,6 +2351,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2120
2351
|
timeout: timeout || 0
|
|
2121
2352
|
},
|
|
2122
2353
|
throwOnExpectationFailure: config.oneFailurePerSpec,
|
|
2354
|
+
autoCleanClosures: config.autoCleanClosures,
|
|
2123
2355
|
timer: new j$.Timer()
|
|
2124
2356
|
});
|
|
2125
2357
|
return spec;
|
|
@@ -2149,9 +2381,14 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2149
2381
|
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
|
2150
2382
|
ensureIsFunctionOrAsync(fn, 'it');
|
|
2151
2383
|
}
|
|
2384
|
+
|
|
2385
|
+
if (timeout) {
|
|
2386
|
+
j$.util.validateTimeout(timeout);
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2152
2389
|
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
|
2153
|
-
if (currentDeclarationSuite.
|
|
2154
|
-
spec.
|
|
2390
|
+
if (currentDeclarationSuite.markedExcluding) {
|
|
2391
|
+
spec.exclude();
|
|
2155
2392
|
}
|
|
2156
2393
|
currentDeclarationSuite.addChild(spec);
|
|
2157
2394
|
return spec;
|
|
@@ -2165,13 +2402,17 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2165
2402
|
ensureIsFunctionOrAsync(fn, 'xit');
|
|
2166
2403
|
}
|
|
2167
2404
|
var spec = this.it.apply(this, arguments);
|
|
2168
|
-
spec.
|
|
2405
|
+
spec.exclude('Temporarily disabled with xit');
|
|
2169
2406
|
return spec;
|
|
2170
2407
|
};
|
|
2171
2408
|
|
|
2172
2409
|
this.fit = function(description, fn, timeout) {
|
|
2173
2410
|
ensureIsNotNested('fit');
|
|
2174
2411
|
ensureIsFunctionOrAsync(fn, 'fit');
|
|
2412
|
+
|
|
2413
|
+
if (timeout) {
|
|
2414
|
+
j$.util.validateTimeout(timeout);
|
|
2415
|
+
}
|
|
2175
2416
|
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
|
2176
2417
|
currentDeclarationSuite.addChild(spec);
|
|
2177
2418
|
focusedRunnables.push(spec.id);
|
|
@@ -2236,6 +2477,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2236
2477
|
this.beforeEach = function(beforeEachFunction, timeout) {
|
|
2237
2478
|
ensureIsNotNested('beforeEach');
|
|
2238
2479
|
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
|
2480
|
+
|
|
2481
|
+
if (timeout) {
|
|
2482
|
+
j$.util.validateTimeout(timeout);
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2239
2485
|
currentDeclarationSuite.beforeEach({
|
|
2240
2486
|
fn: beforeEachFunction,
|
|
2241
2487
|
timeout: timeout || 0
|
|
@@ -2245,6 +2491,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2245
2491
|
this.beforeAll = function(beforeAllFunction, timeout) {
|
|
2246
2492
|
ensureIsNotNested('beforeAll');
|
|
2247
2493
|
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
|
2494
|
+
|
|
2495
|
+
if (timeout) {
|
|
2496
|
+
j$.util.validateTimeout(timeout);
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2248
2499
|
currentDeclarationSuite.beforeAll({
|
|
2249
2500
|
fn: beforeAllFunction,
|
|
2250
2501
|
timeout: timeout || 0
|
|
@@ -2254,6 +2505,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2254
2505
|
this.afterEach = function(afterEachFunction, timeout) {
|
|
2255
2506
|
ensureIsNotNested('afterEach');
|
|
2256
2507
|
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
|
|
2508
|
+
|
|
2509
|
+
if (timeout) {
|
|
2510
|
+
j$.util.validateTimeout(timeout);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2257
2513
|
afterEachFunction.isCleanup = true;
|
|
2258
2514
|
currentDeclarationSuite.afterEach({
|
|
2259
2515
|
fn: afterEachFunction,
|
|
@@ -2264,6 +2520,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
2264
2520
|
this.afterAll = function(afterAllFunction, timeout) {
|
|
2265
2521
|
ensureIsNotNested('afterAll');
|
|
2266
2522
|
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
|
2523
|
+
|
|
2524
|
+
if (timeout) {
|
|
2525
|
+
j$.util.validateTimeout(timeout);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2267
2528
|
currentDeclarationSuite.afterAll({
|
|
2268
2529
|
fn: afterAllFunction,
|
|
2269
2530
|
timeout: timeout || 0
|
|
@@ -2823,6 +3084,31 @@ getJasmineRequireObj().SetContaining = function(j$) {
|
|
|
2823
3084
|
return SetContaining;
|
|
2824
3085
|
};
|
|
2825
3086
|
|
|
3087
|
+
getJasmineRequireObj().StringContaining = function(j$) {
|
|
3088
|
+
function StringContaining(expected) {
|
|
3089
|
+
if (!j$.isString_(expected)) {
|
|
3090
|
+
throw new Error('Expected is not a String');
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
this.expected = expected;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
StringContaining.prototype.asymmetricMatch = function(other) {
|
|
3097
|
+
if (!j$.isString_(other)) {
|
|
3098
|
+
// Arrays, etc. don't match no matter what their indexOf returns.
|
|
3099
|
+
return false;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
return other.indexOf(this.expected) !== -1;
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
StringContaining.prototype.jasmineToString = function() {
|
|
3106
|
+
return '<jasmine.stringContaining("' + this.expected + '")>';
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
return StringContaining;
|
|
3110
|
+
};
|
|
3111
|
+
|
|
2826
3112
|
getJasmineRequireObj().StringMatching = function(j$) {
|
|
2827
3113
|
function StringMatching(expected) {
|
|
2828
3114
|
if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
|
|
@@ -3019,6 +3305,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
|
3019
3305
|
/**
|
|
3020
3306
|
* Get the "this" object that was passed to a specific invocation of this spy.
|
|
3021
3307
|
* @name Spy#calls#thisFor
|
|
3308
|
+
* @since 3.8.0
|
|
3022
3309
|
* @function
|
|
3023
3310
|
* @param {Integer} index The 0-based invocation index.
|
|
3024
3311
|
* @return {Object?}
|
|
@@ -3180,6 +3467,7 @@ getJasmineRequireObj().Clock = function() {
|
|
|
3180
3467
|
|
|
3181
3468
|
/**
|
|
3182
3469
|
* @class Clock
|
|
3470
|
+
* @since 1.3.0
|
|
3183
3471
|
* @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
|
|
3184
3472
|
* _Note:_ Do not construct this directly. You can get the current clock with
|
|
3185
3473
|
* {@link jasmine.clock}.
|
|
@@ -3822,6 +4110,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
|
3822
4110
|
* Otherwise evaluate the matcher.
|
|
3823
4111
|
* @member
|
|
3824
4112
|
* @name async-matchers#already
|
|
4113
|
+
* @since 3.8.0
|
|
3825
4114
|
* @type {async-matchers}
|
|
3826
4115
|
* @example
|
|
3827
4116
|
* await expectAsync(myPromise).already.toBeResolved();
|
|
@@ -4230,16 +4519,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
|
4230
4519
|
function taggedOnError(error) {
|
|
4231
4520
|
var substituteMsg;
|
|
4232
4521
|
|
|
4233
|
-
if (error) {
|
|
4522
|
+
if (j$.isError_(error)) {
|
|
4234
4523
|
error.jasmineMessage = jasmineMessage + ': ' + error;
|
|
4235
4524
|
} else {
|
|
4236
|
-
|
|
4525
|
+
if (error) {
|
|
4526
|
+
substituteMsg = jasmineMessage + ': ' + error;
|
|
4527
|
+
} else {
|
|
4528
|
+
substituteMsg = jasmineMessage + ' with no error or message';
|
|
4529
|
+
}
|
|
4237
4530
|
|
|
4238
4531
|
if (errorType === 'unhandledRejection') {
|
|
4239
4532
|
substituteMsg +=
|
|
4240
4533
|
'\n' +
|
|
4241
4534
|
'(Tip: to get a useful stack trace, use ' +
|
|
4242
|
-
'Promise.reject(new Error(...)) instead of Promise.reject(
|
|
4535
|
+
'Promise.reject(new Error(...)) instead of Promise.reject(' +
|
|
4536
|
+
(error ? '...' : '') +
|
|
4537
|
+
').)';
|
|
4243
4538
|
}
|
|
4244
4539
|
|
|
4245
4540
|
error = new Error(substituteMsg);
|
|
@@ -5462,9 +5757,33 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
|
5462
5757
|
/**
|
|
5463
5758
|
* @interface AsymmetricEqualityTester
|
|
5464
5759
|
* @classdesc An asymmetric equality tester is an object that can match multiple
|
|
5465
|
-
* objects. Examples include jasmine.any() and jasmine.stringMatching().
|
|
5466
|
-
*
|
|
5467
|
-
*
|
|
5760
|
+
* objects. Examples include jasmine.any() and jasmine.stringMatching(). Jasmine
|
|
5761
|
+
* includes a number of built-in asymmetric equality testers, such as
|
|
5762
|
+
* {@link jasmine.objectContaining}. User-defined asymmetric equality testers are
|
|
5763
|
+
* also supported.
|
|
5764
|
+
*
|
|
5765
|
+
* Asymmetric equality testers work with any matcher, including user-defined
|
|
5766
|
+
* custom matchers, that uses {@link MatchersUtil#equals} or
|
|
5767
|
+
* {@link MatchersUtil#contains}.
|
|
5768
|
+
*
|
|
5769
|
+
* @example
|
|
5770
|
+
* function numberDivisibleBy(divisor) {
|
|
5771
|
+
* return {
|
|
5772
|
+
* asymmetricMatch: function(n) {
|
|
5773
|
+
* return typeof n === 'number' && n % divisor === 0;
|
|
5774
|
+
* },
|
|
5775
|
+
* jasmineToString: function() {
|
|
5776
|
+
* return `<a number divisible by ${divisor}>`;
|
|
5777
|
+
* }
|
|
5778
|
+
* };
|
|
5779
|
+
* }
|
|
5780
|
+
*
|
|
5781
|
+
* var actual = {
|
|
5782
|
+
* n: 2,
|
|
5783
|
+
* otherFields: "don't care"
|
|
5784
|
+
* };
|
|
5785
|
+
*
|
|
5786
|
+
* expect(actual).toEqual(jasmine.objectContaining({n: numberDivisibleBy(2)}));
|
|
5468
5787
|
* @see custom_asymmetric_equality_testers
|
|
5469
5788
|
* @since 2.0.0
|
|
5470
5789
|
*/
|
|
@@ -7690,7 +8009,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
|
7690
8009
|
completedSynchronously = true,
|
|
7691
8010
|
handleError = function handleError(error) {
|
|
7692
8011
|
onException(error);
|
|
7693
|
-
next(error);
|
|
7694
8012
|
},
|
|
7695
8013
|
cleanup = once(function cleanup() {
|
|
7696
8014
|
if (timeoutId !== void 0) {
|
|
@@ -9233,9 +9551,17 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9233
9551
|
/**
|
|
9234
9552
|
* @interface Suite
|
|
9235
9553
|
* @see Env#topSuite
|
|
9554
|
+
* @since 2.0.0
|
|
9236
9555
|
*/
|
|
9237
9556
|
function Suite(attrs) {
|
|
9238
9557
|
this.env = attrs.env;
|
|
9558
|
+
/**
|
|
9559
|
+
* The unique ID of this suite.
|
|
9560
|
+
* @name Suite#id
|
|
9561
|
+
* @readonly
|
|
9562
|
+
* @type {string}
|
|
9563
|
+
* @since 2.0.0
|
|
9564
|
+
*/
|
|
9239
9565
|
this.id = attrs.id;
|
|
9240
9566
|
/**
|
|
9241
9567
|
* The parent of this suite, or null if this is the top suite.
|
|
@@ -9249,12 +9575,15 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9249
9575
|
* @name Suite#description
|
|
9250
9576
|
* @readonly
|
|
9251
9577
|
* @type {string}
|
|
9578
|
+
* @since 2.0.0
|
|
9252
9579
|
*/
|
|
9253
9580
|
this.description = attrs.description;
|
|
9254
9581
|
this.expectationFactory = attrs.expectationFactory;
|
|
9255
9582
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
|
9256
9583
|
this.expectationResultFactory = attrs.expectationResultFactory;
|
|
9257
9584
|
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
|
9585
|
+
this.autoCleanClosures =
|
|
9586
|
+
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
|
9258
9587
|
|
|
9259
9588
|
this.beforeFns = [];
|
|
9260
9589
|
this.afterFns = [];
|
|
@@ -9267,29 +9596,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9267
9596
|
* The suite's children.
|
|
9268
9597
|
* @name Suite#children
|
|
9269
9598
|
* @type {Array.<(Spec|Suite)>}
|
|
9599
|
+
* @since 2.0.0
|
|
9270
9600
|
*/
|
|
9271
9601
|
this.children = [];
|
|
9272
9602
|
|
|
9273
|
-
|
|
9274
|
-
* @typedef SuiteResult
|
|
9275
|
-
* @property {Int} id - The unique id of this suite.
|
|
9276
|
-
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
|
9277
|
-
* @property {String} fullName - The full description including all ancestors of this suite.
|
|
9278
|
-
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
|
9279
|
-
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
|
9280
|
-
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
|
9281
|
-
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
|
9282
|
-
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
|
9283
|
-
*/
|
|
9284
|
-
this.result = {
|
|
9285
|
-
id: this.id,
|
|
9286
|
-
description: this.description,
|
|
9287
|
-
fullName: this.getFullName(),
|
|
9288
|
-
failedExpectations: [],
|
|
9289
|
-
deprecationWarnings: [],
|
|
9290
|
-
duration: null,
|
|
9291
|
-
properties: null
|
|
9292
|
-
};
|
|
9603
|
+
this.reset();
|
|
9293
9604
|
}
|
|
9294
9605
|
|
|
9295
9606
|
Suite.prototype.setSuiteProperty = function(key, value) {
|
|
@@ -9310,6 +9621,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9310
9621
|
* @name Suite#getFullName
|
|
9311
9622
|
* @function
|
|
9312
9623
|
* @returns {string}
|
|
9624
|
+
* @since 2.0.0
|
|
9313
9625
|
*/
|
|
9314
9626
|
Suite.prototype.getFullName = function() {
|
|
9315
9627
|
var fullName = [];
|
|
@@ -9325,10 +9637,22 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9325
9637
|
return fullName.join(' ');
|
|
9326
9638
|
};
|
|
9327
9639
|
|
|
9640
|
+
/*
|
|
9641
|
+
* Mark the suite with "pending" status
|
|
9642
|
+
*/
|
|
9328
9643
|
Suite.prototype.pend = function() {
|
|
9329
9644
|
this.markedPending = true;
|
|
9330
9645
|
};
|
|
9331
9646
|
|
|
9647
|
+
/*
|
|
9648
|
+
* Like {@link Suite#pend}, but pending state will survive {@link Spec#reset}
|
|
9649
|
+
* Useful for fdescribe, xdescribe, where pending state should remain.
|
|
9650
|
+
*/
|
|
9651
|
+
Suite.prototype.exclude = function() {
|
|
9652
|
+
this.pend();
|
|
9653
|
+
this.markedExcluding = true;
|
|
9654
|
+
};
|
|
9655
|
+
|
|
9332
9656
|
Suite.prototype.beforeEach = function(fn) {
|
|
9333
9657
|
this.beforeFns.unshift(fn);
|
|
9334
9658
|
};
|
|
@@ -9360,10 +9684,40 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
9360
9684
|
}
|
|
9361
9685
|
|
|
9362
9686
|
Suite.prototype.cleanupBeforeAfter = function() {
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9687
|
+
if (this.autoCleanClosures) {
|
|
9688
|
+
removeFns(this.beforeAllFns);
|
|
9689
|
+
removeFns(this.afterAllFns);
|
|
9690
|
+
removeFns(this.beforeFns);
|
|
9691
|
+
removeFns(this.afterFns);
|
|
9692
|
+
}
|
|
9693
|
+
};
|
|
9694
|
+
|
|
9695
|
+
Suite.prototype.reset = function() {
|
|
9696
|
+
/**
|
|
9697
|
+
* @typedef SuiteResult
|
|
9698
|
+
* @property {Int} id - The unique id of this suite.
|
|
9699
|
+
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
|
9700
|
+
* @property {String} fullName - The full description including all ancestors of this suite.
|
|
9701
|
+
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
|
9702
|
+
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
|
9703
|
+
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
|
9704
|
+
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
|
9705
|
+
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
|
9706
|
+
* @since 2.0.0
|
|
9707
|
+
*/
|
|
9708
|
+
this.result = {
|
|
9709
|
+
id: this.id,
|
|
9710
|
+
description: this.description,
|
|
9711
|
+
fullName: this.getFullName(),
|
|
9712
|
+
failedExpectations: [],
|
|
9713
|
+
deprecationWarnings: [],
|
|
9714
|
+
duration: null,
|
|
9715
|
+
properties: null
|
|
9716
|
+
};
|
|
9717
|
+
this.markedPending = this.markedExcluding;
|
|
9718
|
+
this.children.forEach(function(child) {
|
|
9719
|
+
child.reset();
|
|
9720
|
+
});
|
|
9367
9721
|
};
|
|
9368
9722
|
|
|
9369
9723
|
Suite.prototype.addChild = function(child) {
|
|
@@ -9757,5 +10111,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
|
|
9757
10111
|
};
|
|
9758
10112
|
|
|
9759
10113
|
getJasmineRequireObj().version = function() {
|
|
9760
|
-
return '3.
|
|
10114
|
+
return '3.10.0';
|
|
9761
10115
|
};
|