jasmine-core 4.6.0 → 5.0.0-alpha.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.
package/README.md CHANGED
@@ -32,10 +32,10 @@ Microsoft Edge) as well as Node.
32
32
 
33
33
  | Environment | Supported versions |
34
34
  |-------------------|--------------------|
35
- | Node | 12.17+, 14, 16, 18 |
36
- | Safari | 14-16 |
35
+ | Node | 16.14-16.19, 18 |
36
+ | Safari | 15-16 |
37
37
  | Chrome | Evergreen |
38
- | Firefox | Evergreen, 91, 102 |
38
+ | Firefox | Evergreen, 102 |
39
39
  | Edge | Evergreen |
40
40
 
41
41
  For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us
@@ -1181,6 +1181,7 @@ getJasmineRequireObj().Env = function(j$) {
1181
1181
  let reporter;
1182
1182
  let topSuite;
1183
1183
  let runner;
1184
+ let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel
1184
1185
 
1185
1186
  /**
1186
1187
  * This represents the available options to configure Jasmine.
@@ -1209,6 +1210,10 @@ getJasmineRequireObj().Env = function(j$) {
1209
1210
  seed: null,
1210
1211
  /**
1211
1212
  * Whether to stop execution of the suite after the first spec failure
1213
+ *
1214
+ * <p>In parallel mode, `stopOnSpecFailure` works on a "best effort"
1215
+ * basis. Jasmine will stop execution as soon as practical after a failure
1216
+ * but it might not be immediate.</p>
1212
1217
  * @name Configuration#stopOnSpecFailure
1213
1218
  * @since 3.9.0
1214
1219
  * @type Boolean
@@ -1284,20 +1289,14 @@ getJasmineRequireObj().Env = function(j$) {
1284
1289
 
1285
1290
  if (!options.suppressLoadErrors) {
1286
1291
  installGlobalErrors();
1287
- globalErrors.pushListener(function loadtimeErrorHandler(
1288
- message,
1289
- filename,
1290
- lineno,
1291
- colNo,
1292
- err
1293
- ) {
1292
+ globalErrors.pushListener(function loadtimeErrorHandler(error, event) {
1294
1293
  topSuite.result.failedExpectations.push({
1295
1294
  passed: false,
1296
1295
  globalErrorType: 'load',
1297
- message: message,
1298
- stack: err && err.stack,
1299
- filename: filename,
1300
- lineno: lineno
1296
+ message: error ? error.message : event.message,
1297
+ stack: error && error.stack,
1298
+ filename: event && event.filename,
1299
+ lineno: event && event.lineno
1301
1300
  });
1302
1301
  });
1303
1302
  }
@@ -1515,7 +1514,6 @@ getJasmineRequireObj().Env = function(j$) {
1515
1514
  function(e) {
1516
1515
  (runner.currentRunable() || topSuite).handleException(e);
1517
1516
  };
1518
- options.deprecated = self.deprecated;
1519
1517
 
1520
1518
  new j$.QueueRunner(options).execute();
1521
1519
  }
@@ -1541,6 +1539,7 @@ getJasmineRequireObj().Env = function(j$) {
1541
1539
  * @since 2.0.0
1542
1540
  */
1543
1541
  this.topSuite = function() {
1542
+ ensureNonParallel('topSuite');
1544
1543
  return topSuite.metadata;
1545
1544
  };
1546
1545
 
@@ -1634,21 +1633,25 @@ getJasmineRequireObj().Env = function(j$) {
1634
1633
  reportSpecDone
1635
1634
  });
1636
1635
 
1636
+ this.setParallelLoadingState = function(state) {
1637
+ parallelLoadingState = state;
1638
+ };
1639
+
1640
+ this.parallelReset = function() {
1641
+ // TODO: ensure that autoCleanClosures was false
1642
+ suiteBuilder.parallelReset();
1643
+ runner.parallelReset();
1644
+ };
1645
+
1637
1646
  /**
1638
1647
  * Executes the specs.
1639
1648
  *
1640
- * If called with no parameters or with a falsy value as the first parameter,
1649
+ * If called with no parameter or with a falsy parameter,
1641
1650
  * all specs will be executed except those that are excluded by a
1642
1651
  * [spec filter]{@link Configuration#specFilter} or other mechanism. If the
1643
- * first parameter is a list of spec/suite IDs, only those specs/suites will
1652
+ * parameter is a list of spec/suite IDs, only those specs/suites will
1644
1653
  * be run.
1645
1654
  *
1646
- * Both parameters are optional, but a completion callback is only valid as
1647
- * the second parameter. To specify a completion callback but not a list of
1648
- * specs/suites to run, pass null or undefined as the first parameter. The
1649
- * completion callback is supported for backward compatibility. In most
1650
- * cases it will be more convenient to use the returned promise instead.
1651
- *
1652
1655
  * execute should not be called more than once unless the env has been
1653
1656
  * configured with `{autoCleanClosures: false}`.
1654
1657
  *
@@ -1656,25 +1659,26 @@ getJasmineRequireObj().Env = function(j$) {
1656
1659
  * {@link JasmineDoneInfo|overall result} that's passed to a reporter's
1657
1660
  * `jasmineDone` method, even if the suite did not pass. To determine
1658
1661
  * whether the suite passed, check the value that the promise resolves to
1659
- * or use a {@link Reporter}.
1662
+ * or use a {@link Reporter}. The promise will be rejected in the case of
1663
+ * certain serious errors that prevent execution from starting.
1660
1664
  *
1661
1665
  * @name Env#execute
1662
1666
  * @since 2.0.0
1663
1667
  * @function
1668
+ * @async
1664
1669
  * @param {(string[])=} runablesToRun IDs of suites and/or specs to run
1665
- * @param {Function=} onComplete Function that will be called after all specs have run
1666
1670
  * @return {Promise<JasmineDoneInfo>}
1667
1671
  */
1668
- this.execute = function(runablesToRun, onComplete) {
1672
+ this.execute = async function(runablesToRun) {
1669
1673
  installGlobalErrors();
1670
1674
 
1671
- return runner.execute(runablesToRun).then(function(jasmineDoneInfo) {
1672
- if (onComplete) {
1673
- onComplete();
1674
- }
1675
+ if (parallelLoadingState) {
1676
+ validateConfigForParallel();
1677
+ }
1675
1678
 
1676
- return jasmineDoneInfo;
1677
- });
1679
+ const result = await runner.execute(runablesToRun);
1680
+ this.cleanup_();
1681
+ return result;
1678
1682
  };
1679
1683
 
1680
1684
  /**
@@ -1686,6 +1690,10 @@ getJasmineRequireObj().Env = function(j$) {
1686
1690
  * @see custom_reporter
1687
1691
  */
1688
1692
  this.addReporter = function(reporterToAdd) {
1693
+ if (parallelLoadingState) {
1694
+ throw new Error('Reporters cannot be added via Env in parallel mode');
1695
+ }
1696
+
1689
1697
  reporter.addReporter(reporterToAdd);
1690
1698
  };
1691
1699
 
@@ -1708,6 +1716,10 @@ getJasmineRequireObj().Env = function(j$) {
1708
1716
  * @function
1709
1717
  */
1710
1718
  this.clearReporters = function() {
1719
+ if (parallelLoadingState) {
1720
+ throw new Error('Reporters cannot be removed via Env in parallel mode');
1721
+ }
1722
+
1711
1723
  reporter.clearReporters();
1712
1724
  };
1713
1725
 
@@ -1807,6 +1819,38 @@ getJasmineRequireObj().Env = function(j$) {
1807
1819
  }
1808
1820
  }
1809
1821
 
1822
+ function ensureNonParallel(method) {
1823
+ if (parallelLoadingState) {
1824
+ throw new Error(`'${method}' is not available in parallel mode`);
1825
+ }
1826
+ }
1827
+
1828
+ function ensureNonParallelOrInDescribe(msg) {
1829
+ if (parallelLoadingState && !suiteBuilder.inDescribe()) {
1830
+ throw new Error(msg);
1831
+ }
1832
+ }
1833
+
1834
+ function ensureNonParallelOrInHelperOrInDescribe(method) {
1835
+ if (parallelLoadingState === 'specs' && !suiteBuilder.inDescribe()) {
1836
+ throw new Error(
1837
+ 'In parallel mode, ' +
1838
+ method +
1839
+ ' must be in a describe block or in a helper file'
1840
+ );
1841
+ }
1842
+ }
1843
+
1844
+ function validateConfigForParallel() {
1845
+ if (!config.random) {
1846
+ throw new Error('Randomization cannot be disabled in parallel mode');
1847
+ }
1848
+
1849
+ if (config.seed !== null && config.seed !== undefined) {
1850
+ throw new Error('Random seed cannot be set in parallel mode');
1851
+ }
1852
+ }
1853
+
1810
1854
  this.describe = function(description, definitionFn) {
1811
1855
  ensureIsNotNested('describe');
1812
1856
  const filename = callerCallerFilename();
@@ -1823,6 +1867,7 @@ getJasmineRequireObj().Env = function(j$) {
1823
1867
 
1824
1868
  this.fdescribe = function(description, definitionFn) {
1825
1869
  ensureIsNotNested('fdescribe');
1870
+ ensureNonParallel('fdescribe');
1826
1871
  const filename = callerCallerFilename();
1827
1872
  return suiteBuilder.fdescribe(description, definitionFn, filename)
1828
1873
  .metadata;
@@ -1864,6 +1909,7 @@ getJasmineRequireObj().Env = function(j$) {
1864
1909
 
1865
1910
  this.fit = function(description, fn, timeout) {
1866
1911
  ensureIsNotNested('fit');
1912
+ ensureNonParallel('fit');
1867
1913
  const filename = callerCallerFilename();
1868
1914
  return suiteBuilder.fit(description, fn, timeout, filename).metadata;
1869
1915
  };
@@ -1937,21 +1983,37 @@ getJasmineRequireObj().Env = function(j$) {
1937
1983
 
1938
1984
  this.beforeEach = function(beforeEachFunction, timeout) {
1939
1985
  ensureIsNotNested('beforeEach');
1986
+ ensureNonParallelOrInHelperOrInDescribe('beforeEach');
1940
1987
  suiteBuilder.beforeEach(beforeEachFunction, timeout);
1941
1988
  };
1942
1989
 
1943
1990
  this.beforeAll = function(beforeAllFunction, timeout) {
1944
1991
  ensureIsNotNested('beforeAll');
1992
+ // This message is -npm-specific, but currently parallel operation is
1993
+ // only supported via -npm.
1994
+ ensureNonParallelOrInDescribe(
1995
+ "In parallel mode, 'beforeAll' " +
1996
+ 'must be in a describe block. Use the globalSetup config ' +
1997
+ 'property for exactly-once setup in parallel mode.'
1998
+ );
1945
1999
  suiteBuilder.beforeAll(beforeAllFunction, timeout);
1946
2000
  };
1947
2001
 
1948
2002
  this.afterEach = function(afterEachFunction, timeout) {
1949
2003
  ensureIsNotNested('afterEach');
2004
+ ensureNonParallelOrInHelperOrInDescribe('afterEach');
1950
2005
  suiteBuilder.afterEach(afterEachFunction, timeout);
1951
2006
  };
1952
2007
 
1953
2008
  this.afterAll = function(afterAllFunction, timeout) {
1954
2009
  ensureIsNotNested('afterAll');
2010
+ // This message is -npm-specific, but currently parallel operation is
2011
+ // only supported via -npm.
2012
+ ensureNonParallelOrInDescribe(
2013
+ "In parallel mode, 'afterAll' " +
2014
+ 'must be in a describe block. Use the globalTeardown config ' +
2015
+ 'property for exactly-once teardown in parallel mode.'
2016
+ );
1955
2017
  suiteBuilder.afterAll(afterAllFunction, timeout);
1956
2018
  };
1957
2019
 
@@ -2006,7 +2068,10 @@ getJasmineRequireObj().Env = function(j$) {
2006
2068
  }
2007
2069
 
2008
2070
  function callerCallerFilename() {
2009
- return new j$.StackTrace(new Error()).frames[3].file;
2071
+ const frames = new j$.StackTrace(new Error()).frames;
2072
+ // frames[3] should always exist except in Jasmine's own tests, which bypass
2073
+ // the global it/describe layer, but don't crash if it doesn't.
2074
+ return frames[3] && frames[3].file;
2010
2075
  }
2011
2076
 
2012
2077
  return Env;
@@ -4005,18 +4070,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4005
4070
  let overrideHandler = null,
4006
4071
  onRemoveOverrideHandler = null;
4007
4072
 
4008
- function onerror(message, source, lineno, colno, error) {
4073
+ function onBrowserError(event) {
4074
+ dispatchBrowserError(event.error, event);
4075
+ }
4076
+
4077
+ function dispatchBrowserError(error, event) {
4009
4078
  if (overrideHandler) {
4010
- overrideHandler(error || message);
4079
+ overrideHandler(error);
4011
4080
  return;
4012
4081
  }
4013
4082
 
4014
4083
  const handler = handlers[handlers.length - 1];
4015
4084
 
4016
4085
  if (handler) {
4017
- handler.apply(null, Array.prototype.slice.call(arguments, 0));
4086
+ handler(error, event);
4018
4087
  } else {
4019
- throw arguments[0];
4088
+ throw error;
4020
4089
  }
4021
4090
  }
4022
4091
 
@@ -4093,8 +4162,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4093
4162
  this.installOne_('uncaughtException', 'Uncaught exception');
4094
4163
  this.installOne_('unhandledRejection', 'Unhandled promise rejection');
4095
4164
  } else {
4096
- const originalHandler = global.onerror;
4097
- global.onerror = onerror;
4165
+ global.addEventListener('error', onBrowserError);
4098
4166
 
4099
4167
  const browserRejectionHandler = function browserRejectionHandler(
4100
4168
  event
@@ -4102,16 +4170,19 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4102
4170
  if (j$.isError_(event.reason)) {
4103
4171
  event.reason.jasmineMessage =
4104
4172
  'Unhandled promise rejection: ' + event.reason;
4105
- global.onerror(event.reason);
4173
+ dispatchBrowserError(event.reason, event);
4106
4174
  } else {
4107
- global.onerror('Unhandled promise rejection: ' + event.reason);
4175
+ dispatchBrowserError(
4176
+ 'Unhandled promise rejection: ' + event.reason,
4177
+ event
4178
+ );
4108
4179
  }
4109
4180
  };
4110
4181
 
4111
4182
  global.addEventListener('unhandledrejection', browserRejectionHandler);
4112
4183
 
4113
4184
  this.uninstall = function uninstall() {
4114
- global.onerror = originalHandler;
4185
+ global.removeEventListener('error', onBrowserError);
4115
4186
  global.removeEventListener(
4116
4187
  'unhandledrejection',
4117
4188
  browserRejectionHandler
@@ -4120,6 +4191,13 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4120
4191
  }
4121
4192
  };
4122
4193
 
4194
+ // The listener at the top of the stack will be called with two arguments:
4195
+ // the error and the event. Either of them may be falsy.
4196
+ // The error will normally be provided, but will be falsy in the case of
4197
+ // some browser load-time errors. The event will normally be provided in
4198
+ // browsers but will be falsy in Node.
4199
+ // Listeners that are pushed after spec files have been loaded should be
4200
+ // able to just use the error parameter.
4123
4201
  this.pushListener = function pushListener(listener) {
4124
4202
  handlers.push(listener);
4125
4203
  };
@@ -7450,6 +7528,15 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
7450
7528
  };
7451
7529
 
7452
7530
  getJasmineRequireObj().QueueRunner = function(j$) {
7531
+ /*
7532
+ QueueRunner isn't part of the public interface, but it is used by
7533
+ jasmine-npm. -core and -npm version in lockstep at the major and minor
7534
+ levels but version independently at the patch level. Any changes that
7535
+ would break -npm should be done in a major or minor release, never a
7536
+ patch release, and accompanied by a change to -npm that's released in
7537
+ the same version.
7538
+ */
7539
+
7453
7540
  let nextid = 1;
7454
7541
 
7455
7542
  function StopExecutionError() {}
@@ -7513,15 +7600,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7513
7600
  if (typeof this.onComplete !== 'function') {
7514
7601
  throw new Error('invalid onComplete ' + JSON.stringify(this.onComplete));
7515
7602
  }
7516
- this.deprecated = attrs.deprecated;
7517
7603
  }
7518
7604
 
7519
7605
  QueueRunner.prototype.execute = function() {
7520
- this.handleFinalError = (message, source, lineno, colno, error) => {
7521
- // Older browsers would send the error as the first parameter. HTML5
7522
- // specifies the the five parameters above. The error instance should
7523
- // be preffered, otherwise the call stack would get lost.
7524
- this.onException(error || message);
7606
+ this.handleFinalError = error => {
7607
+ this.onException(error);
7525
7608
  };
7526
7609
  this.globalErrors.pushListener(this.handleFinalError);
7527
7610
  this.run(0);
@@ -7740,6 +7823,15 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7740
7823
  };
7741
7824
 
7742
7825
  getJasmineRequireObj().ReportDispatcher = function(j$) {
7826
+ /*
7827
+ ReportDispatcher isn't part of the public interface, but it is used by
7828
+ jasmine-npm. -core and -npm version in lockstep at the major and minor
7829
+ levels but version independently at the patch level. Any changes that
7830
+ would break -npm should be done in a major or minor release, never a
7831
+ patch release, and accompanied by a change to -npm that's released in
7832
+ the same version.
7833
+ */
7834
+
7743
7835
  function ReportDispatcher(methods, queueRunnerFactory, onLateError) {
7744
7836
  const dispatchedMethods = methods || [];
7745
7837
 
@@ -8411,6 +8503,7 @@ getJasmineRequireObj().Runner = function(j$) {
8411
8503
  class Runner {
8412
8504
  constructor(options) {
8413
8505
  this.topSuite_ = options.topSuite;
8506
+ // TODO use names that read like getters
8414
8507
  this.totalSpecsDefined_ = options.totalSpecsDefined;
8415
8508
  this.focusedRunables_ = options.focusedRunables;
8416
8509
  this.runableResources_ = options.runableResources;
@@ -8435,11 +8528,11 @@ getJasmineRequireObj().Runner = function(j$) {
8435
8528
  ];
8436
8529
  }
8437
8530
 
8438
- // Although execute returns a promise, it isn't async for backwards
8439
- // compatibility: The "Invalid order" exception needs to be propagated
8440
- // synchronously from Env#execute.
8441
- // TODO: make this and Env#execute async in the next major release
8442
- execute(runablesToRun) {
8531
+ parallelReset() {
8532
+ this.executedBefore_ = false;
8533
+ }
8534
+
8535
+ async execute(runablesToRun) {
8443
8536
  if (this.executedBefore_) {
8444
8537
  this.topSuite_.reset();
8445
8538
  }
@@ -8535,13 +8628,17 @@ getJasmineRequireObj().Runner = function(j$) {
8535
8628
  /**
8536
8629
  * Information passed to the {@link Reporter#jasmineStarted} event.
8537
8630
  * @typedef JasmineStartedInfo
8538
- * @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
8539
- * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
8631
+ * @property {Int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
8632
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
8633
+ * @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
8540
8634
  * @since 2.0.0
8541
8635
  */
8542
8636
  await this.reporter_.jasmineStarted({
8637
+ // In parallel mode, the jasmineStarted event is separately dispatched
8638
+ // by jasmine-npm. This event only reaches reporters in non-parallel.
8543
8639
  totalSpecsDefined,
8544
- order: order
8640
+ order: order,
8641
+ parallel: false
8545
8642
  });
8546
8643
 
8547
8644
  this.currentlyExecutingSuites_.push(this.topSuite_);
@@ -8553,7 +8650,7 @@ getJasmineRequireObj().Runner = function(j$) {
8553
8650
 
8554
8651
  this.runableResources_.clearForRunable(this.topSuite_.id);
8555
8652
  this.currentlyExecutingSuites_.pop();
8556
- let overallStatus, incompleteReason;
8653
+ let overallStatus, incompleteReason, incompleteCode;
8557
8654
 
8558
8655
  if (
8559
8656
  this.hasFailures ||
@@ -8563,9 +8660,11 @@ getJasmineRequireObj().Runner = function(j$) {
8563
8660
  } else if (this.focusedRunables_().length > 0) {
8564
8661
  overallStatus = 'incomplete';
8565
8662
  incompleteReason = 'fit() or fdescribe() was found';
8663
+ incompleteCode = 'focused';
8566
8664
  } else if (totalSpecsDefined === 0) {
8567
8665
  overallStatus = 'incomplete';
8568
8666
  incompleteReason = 'No specs found';
8667
+ incompleteCode = 'noSpecsFound';
8569
8668
  } else {
8570
8669
  overallStatus = 'passed';
8571
8670
  }
@@ -8575,8 +8674,10 @@ getJasmineRequireObj().Runner = function(j$) {
8575
8674
  * @typedef JasmineDoneInfo
8576
8675
  * @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
8577
8676
  * @property {Int} totalTime - The total time (in ms) that it took to execute the suite
8578
- * @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
8579
- * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
8677
+ * @property {String} incompleteReason - Human-readable explanation of why the suite was incomplete.
8678
+ * @property {String} incompleteCode - Machine-readable explanation of why the suite was incomplete: 'focused', 'noSpecsFound', or undefined.
8679
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
8680
+ * @property {Int} numWorkers - Number of parallel workers. Note that this property is only present when Jasmine is run in parallel mode.
8580
8681
  * @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
8581
8682
  * @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
8582
8683
  * @since 2.4.0
@@ -8585,6 +8686,7 @@ getJasmineRequireObj().Runner = function(j$) {
8585
8686
  overallStatus: overallStatus,
8586
8687
  totalTime: jasmineTimer.elapsed(),
8587
8688
  incompleteReason: incompleteReason,
8689
+ incompleteCode: incompleteCode,
8588
8690
  order: order,
8589
8691
  failedExpectations: this.topSuite_.result.failedExpectations,
8590
8692
  deprecationWarnings: this.topSuite_.result.deprecationWarnings
@@ -9670,6 +9772,10 @@ getJasmineRequireObj().Suite = function(j$) {
9670
9772
  this.reportedDone = false;
9671
9773
  };
9672
9774
 
9775
+ Suite.prototype.removeChildren = function() {
9776
+ this.children = [];
9777
+ };
9778
+
9673
9779
  Suite.prototype.addChild = function(child) {
9674
9780
  this.children.push(child);
9675
9781
  };
@@ -9885,6 +9991,17 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
9885
9991
  this.focusedRunables = [];
9886
9992
  }
9887
9993
 
9994
+ inDescribe() {
9995
+ return this.currentDeclarationSuite_ !== this.topSuite;
9996
+ }
9997
+
9998
+ parallelReset() {
9999
+ this.topSuite.removeChildren();
10000
+ this.topSuite.reset();
10001
+ this.totalSpecsDefined = 0;
10002
+ this.focusedRunables = [];
10003
+ }
10004
+
9888
10005
  describe(description, definitionFn, filename) {
9889
10006
  ensureIsFunction(definitionFn, 'describe');
9890
10007
  const suite = this.suiteFactory_(description, filename);
@@ -10176,6 +10293,15 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
10176
10293
  };
10177
10294
 
10178
10295
  getJasmineRequireObj().Timer = function() {
10296
+ /*
10297
+ Timer isn't part of the public interface, but it is used by
10298
+ jasmine-npm. -core and -npm version in lockstep at the major and minor
10299
+ levels but version independently at the patch level. Any changes that
10300
+ would break -npm should be done in a major or minor release, never a
10301
+ patch release, and accompanied by a change to -npm that's released in
10302
+ the same version.
10303
+ */
10304
+
10179
10305
  const defaultNow = (function(Date) {
10180
10306
  return function() {
10181
10307
  return new Date().getTime();
@@ -10484,5 +10610,5 @@ getJasmineRequireObj().UserContext = function(j$) {
10484
10610
  };
10485
10611
 
10486
10612
  getJasmineRequireObj().version = function() {
10487
- return '4.6.0';
10613
+ return '5.0.0-alpha.0';
10488
10614
  };
@@ -6,36 +6,48 @@
6
6
  const jasmineRequire = require('./jasmine-core/jasmine.js');
7
7
  module.exports = jasmineRequire;
8
8
 
9
+ const bootOnce = (function() {
10
+ let jasmine, jasmineInterface;
11
+
12
+ return function bootWithoutGlobals() {
13
+ if (!jasmineInterface) {
14
+ jasmine = jasmineRequire.core(jasmineRequire);
15
+ const env = jasmine.getEnv({ suppressLoadErrors: true });
16
+ jasmineInterface = jasmineRequire.interface(jasmine, env);
17
+ }
18
+
19
+ return {jasmine, jasmineInterface};
20
+ };
21
+ }());
22
+
9
23
  /**
10
24
  * Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
25
+ * If boot is called multiple times, the same object is returned every time.
11
26
  * @type {function}
12
27
  * @return {jasmine}
13
28
  */
14
- module.exports.boot = require('./jasmine-core/node_boot.js');
29
+ module.exports.boot = function() {
30
+ const {jasmine, jasmineInterface} = bootOnce();
31
+
32
+ for (const k in jasmineInterface) {
33
+ global[k] = jasmineInterface[k];
34
+ }
35
+
36
+ return jasmine;
37
+ };
15
38
 
16
39
  /**
17
40
  * Boots a copy of Jasmine and returns an object containing the properties
18
41
  * that would normally be added to the global object. If noGlobals is called
19
42
  * multiple times, the same object is returned every time.
20
43
  *
21
- * Do not call boot() if you also call noGlobals().
22
- *
23
44
  * @example
24
45
  * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
25
46
  */
26
- module.exports.noGlobals = (function() {
27
- let jasmineInterface;
28
-
29
- return function bootWithoutGlobals() {
30
- if (!jasmineInterface) {
31
- const jasmine = jasmineRequire.core(jasmineRequire);
32
- const env = jasmine.getEnv({ suppressLoadErrors: true });
33
- jasmineInterface = jasmineRequire.interface(jasmine, env);
34
- }
35
-
36
- return jasmineInterface;
37
- };
38
- }());
47
+ module.exports.noGlobals = function() {
48
+ const {jasmineInterface} = bootOnce();
49
+ return jasmineInterface;
50
+ };
39
51
 
40
52
  const path = require('path'),
41
53
  fs = require('fs');
@@ -43,10 +55,9 @@ const path = require('path'),
43
55
  const rootPath = path.join(__dirname, 'jasmine-core'),
44
56
  bootFiles = ['boot0.js', 'boot1.js'],
45
57
  legacyBootFiles = ['boot.js'],
46
- nodeBootFiles = ['node_boot.js'],
47
58
  cssFiles = [],
48
59
  jsFiles = [],
49
- jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles, nodeBootFiles);
60
+ jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
50
61
 
51
62
  fs.readdirSync(rootPath).forEach(function(file) {
52
63
  if(fs.statSync(path.join(rootPath, file)).isFile()) {
@@ -56,18 +67,18 @@ fs.readdirSync(rootPath).forEach(function(file) {
56
67
  break;
57
68
  case '.js':
58
69
  if (jsFilesToSkip.indexOf(file) < 0) {
59
- jsFiles.push(file);
60
- }
70
+ jsFiles.push(file);
71
+ }
61
72
  break;
62
73
  }
63
74
  }
64
75
  });
65
76
 
66
77
  module.exports.files = {
78
+ self: __filename,
67
79
  path: rootPath,
68
80
  bootDir: rootPath,
69
81
  bootFiles: bootFiles,
70
- nodeBootFiles: nodeBootFiles,
71
82
  cssFiles: cssFiles,
72
83
  jsFiles: ['jasmine.js'].concat(jsFiles),
73
84
  imagesDir: path.join(__dirname, '../images')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jasmine-core",
3
3
  "license": "MIT",
4
- "version": "4.6.0",
4
+ "version": "5.0.0-alpha.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/jasmine/jasmine.git"
@@ -43,7 +43,7 @@
43
43
  "grunt-contrib-concat": "^2.0.0",
44
44
  "grunt-css-url-embed": "^1.11.1",
45
45
  "grunt-sass": "^3.0.2",
46
- "jasmine": "^4.1.0",
46
+ "jasmine": "github:jasmine/jasmine-npm#5.0",
47
47
  "jasmine-browser-runner": "^1.0.0",
48
48
  "jsdom": "^19.0.0",
49
49
  "load-grunt-tasks": "^5.1.0",
@@ -101,10 +101,9 @@
101
101
  }
102
102
  },
103
103
  "browserslist": [
104
- "Safari >= 14",
104
+ "Safari >= 15",
105
+ "Firefox >= 102",
105
106
  "last 2 Chrome versions",
106
- "last 2 Firefox versions",
107
- "Firefox >= 91",
108
107
  "last 2 Edge versions"
109
108
  ]
110
109
  }
@@ -1,38 +0,0 @@
1
- /*
2
- Copyright (c) 2008-2023 Pivotal Labs
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- */
23
- module.exports = function(jasmineRequire) {
24
- const jasmine = jasmineRequire.core(jasmineRequire);
25
-
26
- const env = jasmine.getEnv({ suppressLoadErrors: true });
27
-
28
- const jasmineInterface = jasmineRequire.interface(jasmine, env);
29
-
30
- extend(global, jasmineInterface);
31
-
32
- function extend(destination, source) {
33
- for (const property in source) destination[property] = source[property];
34
- return destination;
35
- }
36
-
37
- return jasmine;
38
- };