jasmine-core 3.10.1 → 4.0.1

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.
package/README.md CHANGED
@@ -11,6 +11,9 @@ Jasmine is a Behavior Driven Development testing framework for JavaScript. It do
11
11
  Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
12
12
  For a quick start guide of Jasmine, see the beginning of [http://jasmine.github.io/edge/introduction.html](http://jasmine.github.io/edge/introduction.html).
13
13
 
14
+ Upgrading from Jasmine 3.x? Check out the 4.0 release notes for a list of
15
+ what's new (including breaking changes). You can also read the [upgrade guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0).
16
+
14
17
  ## Contributing
15
18
 
16
19
  Please read the [contributors' guide](https://github.com/jasmine/jasmine/blob/main/.github/CONTRIBUTING.md).
@@ -23,9 +26,6 @@ For the Jasmine NPM module:<br>
23
26
  For the Jasmine browser runner:<br>
24
27
  [https://github.com/jasmine/jasmine-browser](https://github.com/jasmine/jasmine-browser).
25
28
 
26
- For the Jasmine Ruby Gem:<br>
27
- [https://github.com/jasmine/jasmine-gem](https://github.com/jasmine/jasmine-gem).
28
-
29
29
  To install Jasmine standalone on your local box (where **_{#.#.#}_** below is substituted by the release number downloaded):
30
30
 
31
31
  * Download the standalone distribution for your desired release from the [releases page](https://github.com/jasmine/jasmine/releases).
@@ -47,21 +47,24 @@ Add the following to your HTML file:
47
47
 
48
48
  ## Supported environments
49
49
 
50
- Jasmine tests itself across many browsers (Safari, Chrome, Firefox, Microsoft Edge, and Internet Explorer) as well as nodejs.
50
+ Jasmine tests itself across popular browsers (Safari, Chrome, Firefox, and
51
+ Microsoft Edge) as well as nodejs.
51
52
 
52
53
  | Environment | Supported versions |
53
54
  |-------------------|--------------------|
54
- | Node | 10, 12, 14, 16 |
55
- | Safari | 8-14 |
55
+ | Node | 12.17+, 14, 16 |
56
+ | Safari | 14-15 |
56
57
  | Chrome | Evergreen |
57
- | Firefox | Evergreen, 68, 78 |
58
+ | Firefox | Evergreen, 91 |
58
59
  | Edge | Evergreen |
59
- | Internet Explorer | 10, 11 |
60
60
 
61
61
  For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us
62
62
  at the time of release. Other browsers, as well as older & newer versions of some supported browsers, are likely to work.
63
63
  However, Jasmine isn't tested against them and they aren't actively supported.
64
64
 
65
+ See the [release notes](https://github.com/jasmine/jasmine/tree/main/release_notes)
66
+ for the supported environments for each Jasmine release.
67
+
65
68
  ## Support
66
69
 
67
70
  * Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js).
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2021 Pivotal Labs
2
+ Copyright (c) 2008-2022 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -61,4 +61,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61
61
  for (var property in jasmineInterface) {
62
62
  global[property] = jasmineInterface[property];
63
63
  }
64
- }());
64
+ })();
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2021 Pivotal Labs
2
+ Copyright (c) 2008-2022 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
  /**
24
- This file finishes "booting" Jasmine, performing all of the necessary
24
+ This file finishes 'booting' Jasmine, performing all of the necessary
25
25
  initialization before executing the loaded environment and all of a project's
26
26
  specs. This file should be loaded after `boot0.js` but before any project
27
27
  source files or spec files are loaded. Thus this file can also be used to
@@ -43,24 +43,28 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43
43
  */
44
44
 
45
45
  var queryString = new jasmine.QueryString({
46
- getWindowLocation: function() { return window.location; }
46
+ getWindowLocation: function() {
47
+ return window.location;
48
+ }
47
49
  });
48
50
 
49
- var filterSpecs = !!queryString.getParam("spec");
51
+ var filterSpecs = !!queryString.getParam('spec');
50
52
 
51
53
  var config = {
52
- failFast: queryString.getParam("failFast"),
53
- oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
54
- hideDisabled: queryString.getParam("hideDisabled")
54
+ stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
55
+ stopSpecOnExpectationFailure: queryString.getParam(
56
+ 'stopSpecOnExpectationFailure'
57
+ ),
58
+ hideDisabled: queryString.getParam('hideDisabled')
55
59
  };
56
60
 
57
- var random = queryString.getParam("random");
61
+ var random = queryString.getParam('random');
58
62
 
59
- if (random !== undefined && random !== "") {
63
+ if (random !== undefined && random !== '') {
60
64
  config.random = random;
61
65
  }
62
66
 
63
- var seed = queryString.getParam("seed");
67
+ var seed = queryString.getParam('seed');
64
68
  if (seed) {
65
69
  config.seed = seed;
66
70
  }
@@ -71,11 +75,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71
75
  */
72
76
  var htmlReporter = new jasmine.HtmlReporter({
73
77
  env: env,
74
- navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
75
- addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
76
- getContainer: function() { return document.body; },
77
- createElement: function() { return document.createElement.apply(document, arguments); },
78
- createTextNode: function() { return document.createTextNode.apply(document, arguments); },
78
+ navigateWithNewParam: function(key, value) {
79
+ return queryString.navigateWithNewParam(key, value);
80
+ },
81
+ addToExistingQueryString: function(key, value) {
82
+ return queryString.fullStringWithNewParam(key, value);
83
+ },
84
+ getContainer: function() {
85
+ return document.body;
86
+ },
87
+ createElement: function() {
88
+ return document.createElement.apply(document, arguments);
89
+ },
90
+ createTextNode: function() {
91
+ return document.createTextNode.apply(document, arguments);
92
+ },
79
93
  timer: new jasmine.Timer(),
80
94
  filterSpecs: filterSpecs
81
95
  });
@@ -90,7 +104,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
90
104
  * Filter which specs will be run by matching the start of the full name against the `spec` query param.
91
105
  */
92
106
  var specFilter = new jasmine.HtmlSpecFilter({
93
- filterString: function() { return queryString.getParam("spec"); }
107
+ filterString: function() {
108
+ return queryString.getParam('spec');
109
+ }
94
110
  });
95
111
 
96
112
  config.specFilter = function(spec) {
@@ -99,14 +115,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99
115
 
100
116
  env.configure(config);
101
117
 
102
- /**
103
- * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
104
- */
105
- window.setTimeout = window.setTimeout;
106
- window.setInterval = window.setInterval;
107
- window.clearTimeout = window.clearTimeout;
108
- window.clearInterval = window.clearInterval;
109
-
110
118
  /**
111
119
  * ## Execution
112
120
  *
@@ -121,13 +129,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
121
129
  htmlReporter.initialize();
122
130
  env.execute();
123
131
  };
124
-
125
- /**
126
- * Helper function for readability above.
127
- */
128
- function extend(destination, source) {
129
- for (var property in source) destination[property] = source[property];
130
- return destination;
131
- }
132
-
133
- }());
132
+ })();
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2021 Pivotal Labs
2
+ Copyright (c) 2008-2022 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -72,6 +72,12 @@ jasmineRequire.HtmlReporter = function(j$) {
72
72
  }
73
73
  };
74
74
 
75
+ ResultsStateBuilder.prototype.jasmineDone = function(result) {
76
+ if (result.failedExpectations) {
77
+ this.failureCount += result.failedExpectations.length;
78
+ }
79
+ };
80
+
75
81
  function HtmlReporter(options) {
76
82
  var config = function() {
77
83
  return (options.env && options.env.configuration()) || {};
@@ -187,6 +193,7 @@ jasmineRequire.HtmlReporter = function(j$) {
187
193
  };
188
194
 
189
195
  this.jasmineDone = function(doneResult) {
196
+ stateBuilder.jasmineDone(doneResult);
190
197
  var banner = find('.jasmine-banner');
191
198
  var alert = find('.jasmine-alert');
192
199
  var order = doneResult && doneResult.order;
@@ -303,15 +310,18 @@ jasmineRequire.HtmlReporter = function(j$) {
303
310
  } else {
304
311
  return prefix;
305
312
  }
306
- } else {
313
+ } else if (failure.globalErrorType === 'afterAll') {
307
314
  return afterAllMessagePrefix + failure.message;
315
+ } else {
316
+ return failure.message;
308
317
  }
309
318
  }
310
319
 
311
320
  addDeprecationWarnings(doneResult);
312
321
 
313
322
  for (i = 0; i < deprecationWarnings.length; i++) {
314
- var context;
323
+ var children = [],
324
+ context;
315
325
 
316
326
  switch (deprecationWarnings[i].runnableType) {
317
327
  case 'spec':
@@ -324,13 +334,23 @@ jasmineRequire.HtmlReporter = function(j$) {
324
334
  context = '';
325
335
  }
326
336
 
337
+ deprecationWarnings[i].message.split('\n').forEach(function(line) {
338
+ children.push(line);
339
+ children.push(createDom('br'));
340
+ });
341
+
342
+ children[0] = 'DEPRECATION: ' + children[0];
343
+ children.push(context);
344
+
345
+ if (deprecationWarnings[i].stack) {
346
+ children.push(createExpander(deprecationWarnings[i].stack));
347
+ }
348
+
327
349
  alert.appendChild(
328
350
  createDom(
329
351
  'span',
330
352
  { className: 'jasmine-bar jasmine-warning' },
331
- 'DEPRECATION: ' + deprecationWarnings[i].message,
332
- createDom('br'),
333
- context
353
+ children
334
354
  )
335
355
  );
336
356
  }
@@ -423,9 +443,53 @@ jasmineRequire.HtmlReporter = function(j$) {
423
443
  );
424
444
  }
425
445
 
446
+ if (result.debugLogs) {
447
+ messages.appendChild(debugLogTable(result.debugLogs));
448
+ }
449
+
426
450
  return failure;
427
451
  }
428
452
 
453
+ function debugLogTable(debugLogs) {
454
+ var tbody = createDom('tbody');
455
+
456
+ debugLogs.forEach(function(entry) {
457
+ tbody.appendChild(
458
+ createDom(
459
+ 'tr',
460
+ {},
461
+ createDom('td', {}, entry.timestamp.toString()),
462
+ createDom('td', {}, entry.message)
463
+ )
464
+ );
465
+ });
466
+
467
+ return createDom(
468
+ 'div',
469
+ { className: 'jasmine-debug-log' },
470
+ createDom(
471
+ 'div',
472
+ { className: 'jasmine-debug-log-header' },
473
+ 'Debug logs'
474
+ ),
475
+ createDom(
476
+ 'table',
477
+ {},
478
+ createDom(
479
+ 'thead',
480
+ {},
481
+ createDom(
482
+ 'tr',
483
+ {},
484
+ createDom('th', {}, 'Time (ms)'),
485
+ createDom('th', {}, 'Message')
486
+ )
487
+ ),
488
+ tbody
489
+ )
490
+ );
491
+ }
492
+
429
493
  function summaryList(resultsTree, domParent) {
430
494
  var specListNode;
431
495
  for (var i = 0; i < resultsTree.children.length; i++) {
@@ -560,7 +624,7 @@ jasmineRequire.HtmlReporter = function(j$) {
560
624
  var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
561
625
  failFastCheckbox.checked = config.stopOnSpecFailure;
562
626
  failFastCheckbox.onclick = function() {
563
- navigateWithNewParam('failFast', !config.stopOnSpecFailure);
627
+ navigateWithNewParam('stopOnSpecFailure', !config.stopOnSpecFailure);
564
628
  };
565
629
 
566
630
  var throwCheckbox = optionsMenuDom.querySelector(
@@ -569,7 +633,7 @@ jasmineRequire.HtmlReporter = function(j$) {
569
633
  throwCheckbox.checked = config.stopSpecOnExpectationFailure;
570
634
  throwCheckbox.onclick = function() {
571
635
  navigateWithNewParam(
572
- 'oneFailurePerSpec',
636
+ 'stopSpecOnExpectationFailure',
573
637
  !config.stopSpecOnExpectationFailure
574
638
  );
575
639
  };
@@ -652,17 +716,44 @@ jasmineRequire.HtmlReporter = function(j$) {
652
716
  if (result && result.deprecationWarnings) {
653
717
  for (var i = 0; i < result.deprecationWarnings.length; i++) {
654
718
  var warning = result.deprecationWarnings[i].message;
655
- if (!j$.util.arrayContains(warning)) {
656
- deprecationWarnings.push({
657
- message: warning,
658
- runnableName: result.fullName,
659
- runnableType: runnableType
660
- });
661
- }
719
+ deprecationWarnings.push({
720
+ message: warning,
721
+ stack: result.deprecationWarnings[i].stack,
722
+ runnableName: result.fullName,
723
+ runnableType: runnableType
724
+ });
662
725
  }
663
726
  }
664
727
  }
665
728
 
729
+ function createExpander(stackTrace) {
730
+ var expandLink = createDom('a', { href: '#' }, 'Show stack trace');
731
+ var root = createDom(
732
+ 'div',
733
+ { className: 'jasmine-expander' },
734
+ expandLink,
735
+ createDom(
736
+ 'div',
737
+ { className: 'jasmine-expander-contents jasmine-stack-trace' },
738
+ stackTrace
739
+ )
740
+ );
741
+
742
+ expandLink.addEventListener('click', function(e) {
743
+ e.preventDefault();
744
+
745
+ if (root.classList.contains('jasmine-expanded')) {
746
+ root.classList.remove('jasmine-expanded');
747
+ expandLink.textContent = 'Show stack trace';
748
+ } else {
749
+ root.classList.add('jasmine-expanded');
750
+ expandLink.textContent = 'Hide stack trace';
751
+ }
752
+ });
753
+
754
+ return root;
755
+ }
756
+
666
757
  function find(selector) {
667
758
  return getContainer().querySelector('.jasmine_html-reporter ' + selector);
668
759
  }
@@ -676,11 +767,23 @@ jasmineRequire.HtmlReporter = function(j$) {
676
767
  }
677
768
  }
678
769
 
679
- function createDom(type, attrs, childrenVarArgs) {
680
- var el = createElement(type);
770
+ function createDom(type, attrs, childrenArrayOrVarArgs) {
771
+ var el = createElement(type),
772
+ children,
773
+ i;
774
+
775
+ if (j$.isArray_(childrenArrayOrVarArgs)) {
776
+ children = childrenArrayOrVarArgs;
777
+ } else {
778
+ children = [];
779
+
780
+ for (i = 2; i < arguments.length; i++) {
781
+ children.push(arguments[i]);
782
+ }
783
+ }
681
784
 
682
- for (var i = 2; i < arguments.length; i++) {
683
- var child = arguments[i];
785
+ for (i = 0; i < children.length; i++) {
786
+ var child = children[i];
684
787
 
685
788
  if (typeof child === 'string') {
686
789
  el.appendChild(createTextNode(child));
@@ -165,6 +165,8 @@ body {
165
165
  background-color: #bababa;
166
166
  }
167
167
  .jasmine_html-reporter .jasmine-bar.jasmine-warning {
168
+ margin-top: 14px;
169
+ margin-bottom: 14px;
168
170
  background-color: #ba9d37;
169
171
  color: #333;
170
172
  }
@@ -268,4 +270,34 @@ body {
268
270
  border: 1px solid #ddd;
269
271
  background: white;
270
272
  white-space: pre;
273
+ }
274
+ .jasmine_html-reporter .jasmine-expander a {
275
+ display: block;
276
+ margin-left: 14px;
277
+ color: blue;
278
+ text-decoration: underline;
279
+ }
280
+ .jasmine_html-reporter .jasmine-expander-contents {
281
+ display: none;
282
+ }
283
+ .jasmine_html-reporter .jasmine-expanded {
284
+ padding-bottom: 10px;
285
+ }
286
+ .jasmine_html-reporter .jasmine-expanded .jasmine-expander-contents {
287
+ display: block;
288
+ margin-left: 14px;
289
+ padding: 5px;
290
+ }
291
+ .jasmine_html-reporter .jasmine-debug-log {
292
+ margin: 5px 0 0 0;
293
+ padding: 5px;
294
+ color: #666;
295
+ border: 1px solid #ddd;
296
+ background: white;
297
+ }
298
+ .jasmine_html-reporter .jasmine-debug-log table {
299
+ border-spacing: 0;
300
+ }
301
+ .jasmine_html-reporter .jasmine-debug-log table, .jasmine_html-reporter .jasmine-debug-log th, .jasmine_html-reporter .jasmine-debug-log td {
302
+ border: 1px solid #ddd;
271
303
  }