jasmine-core 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f18ca3911368d543ae8408f8b0a3335e4877d5607b7c79d0d294560e6dcc5f71
4
- data.tar.gz: a4e42a0fa683e962a106f9200e2afce59d58ad3b1610f215e265090de676e2ce
3
+ metadata.gz: 84c11baffb01d3c56c6968d09ddac1b424a13ad98e213c0650659dd7b95caa18
4
+ data.tar.gz: dd4310821ea95c3a49aca3f39be0661b3f5b2cc30978ba6a055fa2f5f9470848
5
5
  SHA512:
6
- metadata.gz: 7f77c1242debc79d4409c576d2a8463c9e0d4c9582c01b0db6cc9f362aed4cb15356a67b2959f811318d2269b00417e7a1ee5f17f8ac7e2fc8d937b31e57e222
7
- data.tar.gz: 34af5b076d8b89012961210b1e2dbeff6d7dfd17447deac859df212b7e68d302c108155415b066abd0dae3a1d5962ccb2618c17c27d38890311829847c33fc03
6
+ metadata.gz: f6af4a7da56dbcbb0fc0ce68d9912953a11238d8dee921ea412b737a6f89b538f8b0e4b1e5e23e8595afb37f127163739a9182634d69406ef969386377497ed6
7
+ data.tar.gz: 0b594b10d7f30584a41b7cd220fc07d1e020b50ec00632f0e1d2c3652c83374ca45758113519c54f2131f75246ceafb49576be9ae074abe3c0f31db2d3082590
@@ -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 to complete.
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
- j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
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;
@@ -397,7 +420,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
397
420
  };
398
421
 
399
422
  /**
400
- * Get a matcher, 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
+ * 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
424
  * that will succeed if the actual value being compared is an instance of the specified class/constructor.
402
425
  * @name jasmine.any
403
426
  * @since 1.3.0
@@ -409,7 +432,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
409
432
  };
410
433
 
411
434
  /**
412
- * Get a matcher, 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}),
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}),
413
436
  * that will succeed if the actual value being compared is not `null` and not `undefined`.
414
437
  * @name jasmine.anything
415
438
  * @since 2.2.0
@@ -420,7 +443,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
420
443
  };
421
444
 
422
445
  /**
423
- * Get a matcher, 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}),
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}),
424
447
  * that will succeed if the actual value being compared is `true` or anything truthy.
425
448
  * @name jasmine.truthy
426
449
  * @since 3.1.0
@@ -431,7 +454,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
431
454
  };
432
455
 
433
456
  /**
434
- * Get a matcher, 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}),
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}),
435
458
  * that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
436
459
  * @name jasmine.falsy
437
460
  * @since 3.1.0
@@ -442,7 +465,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
442
465
  };
443
466
 
444
467
  /**
445
- * Get a matcher, 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
+ * 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}),
446
469
  * that will succeed if the actual value being compared is empty.
447
470
  * @name jasmine.empty
448
471
  * @since 3.1.0
@@ -453,7 +476,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
453
476
  };
454
477
 
455
478
  /**
456
- * Get a matcher, 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}),
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}),
457
480
  * that will succeed if the actual value being compared is not empty.
458
481
  * @name jasmine.notEmpty
459
482
  * @since 3.1.0
@@ -464,7 +487,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
464
487
  };
465
488
 
466
489
  /**
467
- * Get a matcher, 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}),
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}),
468
491
  * that will succeed if the actual value being compared contains at least the keys and values.
469
492
  * @name jasmine.objectContaining
470
493
  * @since 1.3.0
@@ -476,7 +499,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
476
499
  };
477
500
 
478
501
  /**
479
- * Get a matcher, 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}),
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}),
480
503
  * that will succeed if the actual value is a `String` that matches the `RegExp` or `String`.
481
504
  * @name jasmine.stringMatching
482
505
  * @since 2.2.0
@@ -488,7 +511,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
488
511
  };
489
512
 
490
513
  /**
491
- * Get a matcher, 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}),
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}),
492
527
  * that will succeed if the actual value is an `Array` that contains at least the elements in the sample.
493
528
  * @name jasmine.arrayContaining
494
529
  * @since 2.2.0
@@ -500,7 +535,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
500
535
  };
501
536
 
502
537
  /**
503
- * Get a matcher, 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}),
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}),
504
539
  * that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
505
540
  * @name jasmine.arrayWithExactContents
506
541
  * @since 2.8.0
@@ -512,7 +547,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
512
547
  };
513
548
 
514
549
  /**
515
- * Get a matcher, 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}),
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}),
516
551
  * that will succeed if every key/value pair in the sample passes the deep equality comparison
517
552
  * with at least one key/value pair in the actual value being compared
518
553
  * @name jasmine.mapContaining
@@ -525,7 +560,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
525
560
  };
526
561
 
527
562
  /**
528
- * Get a matcher, 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}),
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}),
529
564
  * that will succeed if every item in the sample passes the deep equality comparison
530
565
  * with at least one item in the actual value being compared
531
566
  * @name jasmine.setContaining
@@ -700,6 +735,21 @@ getJasmineRequireObj().util = function(j$) {
700
735
  }
701
736
  };
702
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
+
703
753
  return util;
704
754
  };
705
755
 
@@ -707,6 +757,7 @@ getJasmineRequireObj().Spec = function(j$) {
707
757
  /**
708
758
  * @interface Spec
709
759
  * @see Configuration#specFilter
760
+ * @since 2.0.0
710
761
  */
711
762
  function Spec(attrs) {
712
763
  this.expectationFactory = attrs.expectationFactory;
@@ -717,6 +768,7 @@ getJasmineRequireObj().Spec = function(j$) {
717
768
  * @name Spec#id
718
769
  * @readonly
719
770
  * @type {string}
771
+ * @since 2.0.0
720
772
  */
721
773
  this.id = attrs.id;
722
774
  /**
@@ -724,6 +776,7 @@ getJasmineRequireObj().Spec = function(j$) {
724
776
  * @name Spec#description
725
777
  * @readonly
726
778
  * @type {string}
779
+ * @since 2.0.0
727
780
  */
728
781
  this.description = attrs.description || '';
729
782
  this.queueableFn = attrs.queueableFn;
@@ -738,6 +791,8 @@ getJasmineRequireObj().Spec = function(j$) {
738
791
  return {};
739
792
  };
740
793
  this.onStart = attrs.onStart || function() {};
794
+ this.autoCleanClosures =
795
+ attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
741
796
  this.getSpecName =
742
797
  attrs.getSpecName ||
743
798
  function() {
@@ -755,7 +810,7 @@ getJasmineRequireObj().Spec = function(j$) {
755
810
  this.timer = attrs.timer || new j$.Timer();
756
811
 
757
812
  if (!this.queueableFn.fn) {
758
- this.pend();
813
+ this.exclude();
759
814
  }
760
815
 
761
816
  /**
@@ -770,7 +825,8 @@ getJasmineRequireObj().Spec = function(j$) {
770
825
  * @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
771
826
  * @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
772
827
  * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
773
- */
828
+ * @since 2.0.0
829
+ x */
774
830
  this.result = {
775
831
  id: this.id,
776
832
  description: this.description,
@@ -822,7 +878,9 @@ getJasmineRequireObj().Spec = function(j$) {
822
878
 
823
879
  var complete = {
824
880
  fn: function(done) {
825
- self.queueableFn.fn = null;
881
+ if (self.autoCleanClosures) {
882
+ self.queueableFn.fn = null;
883
+ }
826
884
  self.result.status = self.status(excluded, failSpecWithNoExp);
827
885
  self.result.duration = self.timer.elapsed();
828
886
  self.resultCallback(self.result, done);
@@ -859,6 +917,36 @@ getJasmineRequireObj().Spec = function(j$) {
859
917
  this.queueRunnerFactory(runnerConfig);
860
918
  };
861
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
+
862
950
  Spec.prototype.onException = function onException(e) {
863
951
  if (Spec.isPendingSpecException(e)) {
864
952
  this.pend(extractCustomPendingMessage(e));
@@ -882,6 +970,10 @@ getJasmineRequireObj().Spec = function(j$) {
882
970
  );
883
971
  };
884
972
 
973
+ /*
974
+ * Marks state as pending
975
+ * @param {string} [message] An optional reason message
976
+ */
885
977
  Spec.prototype.pend = function(message) {
886
978
  this.markedPending = true;
887
979
  if (message) {
@@ -889,6 +981,19 @@ getJasmineRequireObj().Spec = function(j$) {
889
981
  }
890
982
  };
891
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
+
892
997
  Spec.prototype.getResult = function() {
893
998
  this.result.status = this.status();
894
999
  return this.result;
@@ -921,6 +1026,7 @@ getJasmineRequireObj().Spec = function(j$) {
921
1026
  * @name Spec#getFullName
922
1027
  * @function
923
1028
  * @returns {string}
1029
+ * @since 2.0.0
924
1030
  */
925
1031
  Spec.prototype.getFullName = function() {
926
1032
  return this.getSpecName(this);
@@ -1148,7 +1254,16 @@ getJasmineRequireObj().Env = function(j$) {
1148
1254
  * @type function
1149
1255
  * @default undefined
1150
1256
  */
1151
- 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
1152
1267
  };
1153
1268
 
1154
1269
  var currentSuite = function() {
@@ -1201,7 +1316,8 @@ getJasmineRequireObj().Env = function(j$) {
1201
1316
  var booleanProps = [
1202
1317
  'random',
1203
1318
  'failSpecWithNoExpectations',
1204
- 'hideDisabled'
1319
+ 'hideDisabled',
1320
+ 'autoCleanClosures'
1205
1321
  ];
1206
1322
 
1207
1323
  booleanProps.forEach(function(prop) {
@@ -1442,7 +1558,9 @@ getJasmineRequireObj().Env = function(j$) {
1442
1558
  }
1443
1559
 
1444
1560
  delayedExpectationResult.message +=
1445
- '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()?';
1446
1564
 
1447
1565
  topSuite.result.failedExpectations.push(delayedExpectationResult);
1448
1566
  }
@@ -1507,10 +1625,11 @@ getJasmineRequireObj().Env = function(j$) {
1507
1625
  delete runnableResources[id];
1508
1626
  };
1509
1627
 
1510
- var beforeAndAfterFns = function(suite) {
1628
+ var beforeAndAfterFns = function(targetSuite) {
1511
1629
  return function() {
1512
1630
  var befores = [],
1513
- afters = [];
1631
+ afters = [],
1632
+ suite = targetSuite;
1514
1633
 
1515
1634
  while (suite) {
1516
1635
  befores = befores.concat(suite.beforeFns);
@@ -1711,9 +1830,9 @@ getJasmineRequireObj().Env = function(j$) {
1711
1830
  description: 'Jasmine__TopLevel__Suite',
1712
1831
  expectationFactory: expectationFactory,
1713
1832
  asyncExpectationFactory: suiteAsyncExpectationFactory,
1714
- expectationResultFactory: expectationResultFactory
1833
+ expectationResultFactory: expectationResultFactory,
1834
+ autoCleanClosures: config.autoCleanClosures
1715
1835
  });
1716
- defaultResourcesForRunnable(topSuite.id);
1717
1836
  currentDeclarationSuite = topSuite;
1718
1837
 
1719
1838
  /**
@@ -1722,6 +1841,7 @@ getJasmineRequireObj().Env = function(j$) {
1722
1841
  * @function
1723
1842
  * @name Env#topSuite
1724
1843
  * @return {Suite} the root suite
1844
+ * @since 2.0.0
1725
1845
  */
1726
1846
  this.topSuite = function() {
1727
1847
  return topSuite;
@@ -1830,6 +1950,11 @@ getJasmineRequireObj().Env = function(j$) {
1830
1950
  * @return {Promise<undefined>}
1831
1951
  */
1832
1952
  this.execute = function(runnablesToRun, onComplete) {
1953
+ if (this._executedBefore) {
1954
+ topSuite.reset();
1955
+ }
1956
+ this._executedBefore = true;
1957
+ defaultResourcesForRunnable(topSuite.id);
1833
1958
  installGlobalErrors();
1834
1959
 
1835
1960
  if (!runnablesToRun) {
@@ -1913,6 +2038,7 @@ getJasmineRequireObj().Env = function(j$) {
1913
2038
  * @typedef JasmineStartedInfo
1914
2039
  * @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
1915
2040
  * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
2041
+ * @since 2.0.0
1916
2042
  */
1917
2043
  reporter.jasmineStarted(
1918
2044
  {
@@ -1951,6 +2077,7 @@ getJasmineRequireObj().Env = function(j$) {
1951
2077
  * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
1952
2078
  * @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
1953
2079
  * @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
2080
+ * @since 2.4.0
1954
2081
  */
1955
2082
  reporter.jasmineDone(
1956
2083
  {
@@ -2114,7 +2241,8 @@ getJasmineRequireObj().Env = function(j$) {
2114
2241
  expectationFactory: expectationFactory,
2115
2242
  asyncExpectationFactory: suiteAsyncExpectationFactory,
2116
2243
  expectationResultFactory: expectationResultFactory,
2117
- throwOnExpectationFailure: config.oneFailurePerSpec
2244
+ throwOnExpectationFailure: config.oneFailurePerSpec,
2245
+ autoCleanClosures: config.autoCleanClosures
2118
2246
  });
2119
2247
 
2120
2248
  return suite;
@@ -2127,8 +2255,8 @@ getJasmineRequireObj().Env = function(j$) {
2127
2255
  if (specDefinitions.length > 0) {
2128
2256
  throw new Error('describe does not expect any arguments');
2129
2257
  }
2130
- if (currentDeclarationSuite.markedPending) {
2131
- suite.pend();
2258
+ if (currentDeclarationSuite.markedExcluding) {
2259
+ suite.exclude();
2132
2260
  }
2133
2261
  addSpecsToSuite(suite, specDefinitions);
2134
2262
  return suite;
@@ -2138,7 +2266,7 @@ getJasmineRequireObj().Env = function(j$) {
2138
2266
  ensureIsNotNested('xdescribe');
2139
2267
  ensureIsFunction(specDefinitions, 'xdescribe');
2140
2268
  var suite = suiteFactory(description);
2141
- suite.pend();
2269
+ suite.exclude();
2142
2270
  addSpecsToSuite(suite, specDefinitions);
2143
2271
  return suite;
2144
2272
  };
@@ -2223,6 +2351,7 @@ getJasmineRequireObj().Env = function(j$) {
2223
2351
  timeout: timeout || 0
2224
2352
  },
2225
2353
  throwOnExpectationFailure: config.oneFailurePerSpec,
2354
+ autoCleanClosures: config.autoCleanClosures,
2226
2355
  timer: new j$.Timer()
2227
2356
  });
2228
2357
  return spec;
@@ -2252,9 +2381,14 @@ getJasmineRequireObj().Env = function(j$) {
2252
2381
  if (arguments.length > 1 && typeof fn !== 'undefined') {
2253
2382
  ensureIsFunctionOrAsync(fn, 'it');
2254
2383
  }
2384
+
2385
+ if (timeout) {
2386
+ j$.util.validateTimeout(timeout);
2387
+ }
2388
+
2255
2389
  var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
2256
- if (currentDeclarationSuite.markedPending) {
2257
- spec.pend();
2390
+ if (currentDeclarationSuite.markedExcluding) {
2391
+ spec.exclude();
2258
2392
  }
2259
2393
  currentDeclarationSuite.addChild(spec);
2260
2394
  return spec;
@@ -2268,13 +2402,17 @@ getJasmineRequireObj().Env = function(j$) {
2268
2402
  ensureIsFunctionOrAsync(fn, 'xit');
2269
2403
  }
2270
2404
  var spec = this.it.apply(this, arguments);
2271
- spec.pend('Temporarily disabled with xit');
2405
+ spec.exclude('Temporarily disabled with xit');
2272
2406
  return spec;
2273
2407
  };
2274
2408
 
2275
2409
  this.fit = function(description, fn, timeout) {
2276
2410
  ensureIsNotNested('fit');
2277
2411
  ensureIsFunctionOrAsync(fn, 'fit');
2412
+
2413
+ if (timeout) {
2414
+ j$.util.validateTimeout(timeout);
2415
+ }
2278
2416
  var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
2279
2417
  currentDeclarationSuite.addChild(spec);
2280
2418
  focusedRunnables.push(spec.id);
@@ -2339,6 +2477,11 @@ getJasmineRequireObj().Env = function(j$) {
2339
2477
  this.beforeEach = function(beforeEachFunction, timeout) {
2340
2478
  ensureIsNotNested('beforeEach');
2341
2479
  ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
2480
+
2481
+ if (timeout) {
2482
+ j$.util.validateTimeout(timeout);
2483
+ }
2484
+
2342
2485
  currentDeclarationSuite.beforeEach({
2343
2486
  fn: beforeEachFunction,
2344
2487
  timeout: timeout || 0
@@ -2348,6 +2491,11 @@ getJasmineRequireObj().Env = function(j$) {
2348
2491
  this.beforeAll = function(beforeAllFunction, timeout) {
2349
2492
  ensureIsNotNested('beforeAll');
2350
2493
  ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
2494
+
2495
+ if (timeout) {
2496
+ j$.util.validateTimeout(timeout);
2497
+ }
2498
+
2351
2499
  currentDeclarationSuite.beforeAll({
2352
2500
  fn: beforeAllFunction,
2353
2501
  timeout: timeout || 0
@@ -2357,6 +2505,11 @@ getJasmineRequireObj().Env = function(j$) {
2357
2505
  this.afterEach = function(afterEachFunction, timeout) {
2358
2506
  ensureIsNotNested('afterEach');
2359
2507
  ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
2508
+
2509
+ if (timeout) {
2510
+ j$.util.validateTimeout(timeout);
2511
+ }
2512
+
2360
2513
  afterEachFunction.isCleanup = true;
2361
2514
  currentDeclarationSuite.afterEach({
2362
2515
  fn: afterEachFunction,
@@ -2367,6 +2520,11 @@ getJasmineRequireObj().Env = function(j$) {
2367
2520
  this.afterAll = function(afterAllFunction, timeout) {
2368
2521
  ensureIsNotNested('afterAll');
2369
2522
  ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
2523
+
2524
+ if (timeout) {
2525
+ j$.util.validateTimeout(timeout);
2526
+ }
2527
+
2370
2528
  currentDeclarationSuite.afterAll({
2371
2529
  fn: afterAllFunction,
2372
2530
  timeout: timeout || 0
@@ -2926,6 +3084,31 @@ getJasmineRequireObj().SetContaining = function(j$) {
2926
3084
  return SetContaining;
2927
3085
  };
2928
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
+
2929
3112
  getJasmineRequireObj().StringMatching = function(j$) {
2930
3113
  function StringMatching(expected) {
2931
3114
  if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
@@ -3122,6 +3305,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
3122
3305
  /**
3123
3306
  * Get the "this" object that was passed to a specific invocation of this spy.
3124
3307
  * @name Spy#calls#thisFor
3308
+ * @since 3.8.0
3125
3309
  * @function
3126
3310
  * @param {Integer} index The 0-based invocation index.
3127
3311
  * @return {Object?}
@@ -3283,6 +3467,7 @@ getJasmineRequireObj().Clock = function() {
3283
3467
 
3284
3468
  /**
3285
3469
  * @class Clock
3470
+ * @since 1.3.0
3286
3471
  * @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
3287
3472
  * _Note:_ Do not construct this directly. You can get the current clock with
3288
3473
  * {@link jasmine.clock}.
@@ -3925,6 +4110,7 @@ getJasmineRequireObj().Expectation = function(j$) {
3925
4110
  * Otherwise evaluate the matcher.
3926
4111
  * @member
3927
4112
  * @name async-matchers#already
4113
+ * @since 3.8.0
3928
4114
  * @type {async-matchers}
3929
4115
  * @example
3930
4116
  * await expectAsync(myPromise).already.toBeResolved();
@@ -5571,9 +5757,33 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
5571
5757
  /**
5572
5758
  * @interface AsymmetricEqualityTester
5573
5759
  * @classdesc An asymmetric equality tester is an object that can match multiple
5574
- * objects. Examples include jasmine.any() and jasmine.stringMatching().
5575
- * User-defined asymmetric equality testers can also be defined and used in
5576
- * expectations.
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)}));
5577
5787
  * @see custom_asymmetric_equality_testers
5578
5788
  * @since 2.0.0
5579
5789
  */
@@ -7799,7 +8009,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7799
8009
  completedSynchronously = true,
7800
8010
  handleError = function handleError(error) {
7801
8011
  onException(error);
7802
- next(error);
7803
8012
  },
7804
8013
  cleanup = once(function cleanup() {
7805
8014
  if (timeoutId !== void 0) {
@@ -9342,6 +9551,7 @@ getJasmineRequireObj().Suite = function(j$) {
9342
9551
  /**
9343
9552
  * @interface Suite
9344
9553
  * @see Env#topSuite
9554
+ * @since 2.0.0
9345
9555
  */
9346
9556
  function Suite(attrs) {
9347
9557
  this.env = attrs.env;
@@ -9350,6 +9560,7 @@ getJasmineRequireObj().Suite = function(j$) {
9350
9560
  * @name Suite#id
9351
9561
  * @readonly
9352
9562
  * @type {string}
9563
+ * @since 2.0.0
9353
9564
  */
9354
9565
  this.id = attrs.id;
9355
9566
  /**
@@ -9364,12 +9575,15 @@ getJasmineRequireObj().Suite = function(j$) {
9364
9575
  * @name Suite#description
9365
9576
  * @readonly
9366
9577
  * @type {string}
9578
+ * @since 2.0.0
9367
9579
  */
9368
9580
  this.description = attrs.description;
9369
9581
  this.expectationFactory = attrs.expectationFactory;
9370
9582
  this.asyncExpectationFactory = attrs.asyncExpectationFactory;
9371
9583
  this.expectationResultFactory = attrs.expectationResultFactory;
9372
9584
  this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
9585
+ this.autoCleanClosures =
9586
+ attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
9373
9587
 
9374
9588
  this.beforeFns = [];
9375
9589
  this.afterFns = [];
@@ -9382,29 +9596,11 @@ getJasmineRequireObj().Suite = function(j$) {
9382
9596
  * The suite's children.
9383
9597
  * @name Suite#children
9384
9598
  * @type {Array.<(Spec|Suite)>}
9599
+ * @since 2.0.0
9385
9600
  */
9386
9601
  this.children = [];
9387
9602
 
9388
- /**
9389
- * @typedef SuiteResult
9390
- * @property {Int} id - The unique id of this suite.
9391
- * @property {String} description - The description text passed to the {@link describe} that made this suite.
9392
- * @property {String} fullName - The full description including all ancestors of this suite.
9393
- * @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
9394
- * @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
9395
- * @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
9396
- * @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
9397
- * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
9398
- */
9399
- this.result = {
9400
- id: this.id,
9401
- description: this.description,
9402
- fullName: this.getFullName(),
9403
- failedExpectations: [],
9404
- deprecationWarnings: [],
9405
- duration: null,
9406
- properties: null
9407
- };
9603
+ this.reset();
9408
9604
  }
9409
9605
 
9410
9606
  Suite.prototype.setSuiteProperty = function(key, value) {
@@ -9425,6 +9621,7 @@ getJasmineRequireObj().Suite = function(j$) {
9425
9621
  * @name Suite#getFullName
9426
9622
  * @function
9427
9623
  * @returns {string}
9624
+ * @since 2.0.0
9428
9625
  */
9429
9626
  Suite.prototype.getFullName = function() {
9430
9627
  var fullName = [];
@@ -9440,10 +9637,22 @@ getJasmineRequireObj().Suite = function(j$) {
9440
9637
  return fullName.join(' ');
9441
9638
  };
9442
9639
 
9640
+ /*
9641
+ * Mark the suite with "pending" status
9642
+ */
9443
9643
  Suite.prototype.pend = function() {
9444
9644
  this.markedPending = true;
9445
9645
  };
9446
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
+
9447
9656
  Suite.prototype.beforeEach = function(fn) {
9448
9657
  this.beforeFns.unshift(fn);
9449
9658
  };
@@ -9475,10 +9684,40 @@ getJasmineRequireObj().Suite = function(j$) {
9475
9684
  }
9476
9685
 
9477
9686
  Suite.prototype.cleanupBeforeAfter = function() {
9478
- removeFns(this.beforeAllFns);
9479
- removeFns(this.afterAllFns);
9480
- removeFns(this.beforeFns);
9481
- removeFns(this.afterFns);
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
+ });
9482
9721
  };
9483
9722
 
9484
9723
  Suite.prototype.addChild = function(child) {
@@ -9872,5 +10111,5 @@ getJasmineRequireObj().UserContext = function(j$) {
9872
10111
  };
9873
10112
 
9874
10113
  getJasmineRequireObj().version = function() {
9875
- return '3.9.0';
10114
+ return '3.10.0';
9876
10115
  };
@@ -4,6 +4,6 @@
4
4
  #
5
5
  module Jasmine
6
6
  module Core
7
- VERSION = "3.9.0"
7
+ VERSION = "3.10.0"
8
8
  end
9
9
  end
data/lib/jasmine-core.rb CHANGED
@@ -1,3 +1,28 @@
1
+ if ENV["SUPPRESS_JASMINE_DEPRECATION"].nil?
2
+ puts <<~END_DEPRECATION_MSG
3
+ The Jasmine Ruby gems are deprecated. There will be no further releases after
4
+ the end of the Jasmine 3.x series. We recommend that most users migrate to the
5
+ jasmine-browser-runner npm package, which is the direct replacement for the
6
+ jasmine gem. See <https://jasmine.github.io/setup/browser.html> for setup
7
+ instructions, including for Rails applications that use either Sprockets or
8
+ Webpacker.
9
+
10
+ If jasmine-browser-runner doesn't meet your needs, one of these might:
11
+
12
+ * The jasmine npm package to run specs in Node.js:
13
+ <https://github.com/jasmine/jasmine-npm>
14
+ * The standalone distribution to run specs in browsers with no additional
15
+ tools: <https://github.com/jasmine/jasmine#installation>
16
+ * The jasmine-core npm package if all you need is the Jasmine assets:
17
+ <https://github.com/jasmine/jasmine>. This is the direct equivalent of the
18
+ jasmine-core Ruby gem.
19
+
20
+ To prevent this message from appearing, set the SUPPRESS_JASMINE_DEPRECATION
21
+ environment variable.
22
+
23
+ END_DEPRECATION_MSG
24
+ end
25
+
1
26
  module Jasmine
2
27
  module Core
3
28
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Van Hove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-21 00:00:00.000000000 Z
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,8 +24,17 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Test your JavaScript without any framework dependencies, in any environment,
27
+ description: |
28
+ Test your JavaScript without any framework dependencies, in any environment,
28
29
  and with a nice descriptive syntax.
30
+
31
+ Jasmine for Ruby is deprecated. The direct replacment for the jasmine-core
32
+ gem is the jasmine-core NPM package. If you are also using the jasmine gem,
33
+ we recommend using the jasmine-browser-runner NPM package instead. It
34
+ supports all the same scenarios as the jasmine gem gem plus Webpacker. See
35
+ https://jasmine.github.io/setup/browser.html for setup instructions, and
36
+ https://github.com/jasmine/jasmine-gem/blob/main/release_notes/3.9.0.md
37
+ for other options.
29
38
  email: jasmine-js@googlegroups.com
30
39
  executables: []
31
40
  extensions: []