jasmine-core 5.2.0 → 5.4.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 +11 -7
- package/lib/jasmine-core/jasmine.js +127 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,18 +27,22 @@ for information on writing specs, and [the FAQ](https://jasmine.github.io/pages/
|
|
|
27
27
|
Jasmine tests itself across popular browsers (Safari, Chrome, Firefox, and
|
|
28
28
|
Microsoft Edge) as well as Node.
|
|
29
29
|
|
|
30
|
-
| Environment | Supported versions
|
|
31
|
-
|
|
32
|
-
| Node | 18, 20, 22
|
|
33
|
-
| Safari | 15-17
|
|
34
|
-
| Chrome | Evergreen
|
|
35
|
-
| Firefox | Evergreen, 102
|
|
36
|
-
| Edge | Evergreen
|
|
30
|
+
| Environment | Supported versions |
|
|
31
|
+
|-------------------|----------------------------|
|
|
32
|
+
| Node | 18, 20, 22 |
|
|
33
|
+
| Safari | 15-17 |
|
|
34
|
+
| Chrome | Evergreen |
|
|
35
|
+
| Firefox | Evergreen, 102*, 115*, 128 |
|
|
36
|
+
| Edge | Evergreen |
|
|
37
37
|
|
|
38
38
|
For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us
|
|
39
39
|
at the time of release. Other browsers, as well as older & newer versions of some supported browsers, are likely to work.
|
|
40
40
|
However, Jasmine isn't tested against them and they aren't actively supported.
|
|
41
41
|
|
|
42
|
+
\* Environments that are past end of life are supported on a best-effort basis.
|
|
43
|
+
They may be dropped in a future minor release of Jasmine if continued support
|
|
44
|
+
becomes impractical.
|
|
45
|
+
|
|
42
46
|
To find out what environments work with a particular Jasmine release, see the [release notes](https://github.com/jasmine/jasmine/tree/main/release_notes).
|
|
43
47
|
|
|
44
48
|
## Maintainers
|
|
@@ -915,9 +915,9 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
915
915
|
* @property {String} fullName - The full description including all ancestors of this spec.
|
|
916
916
|
* @property {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe().
|
|
917
917
|
* @property {String} filename - The name of the file the spec was defined in.
|
|
918
|
-
* @property {
|
|
919
|
-
* @property {
|
|
920
|
-
* @property {
|
|
918
|
+
* @property {ExpectationResult[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
|
919
|
+
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
|
920
|
+
* @property {ExpectationResult[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
|
921
921
|
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
|
922
922
|
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
|
923
923
|
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
|
@@ -1429,12 +1429,19 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
1429
1429
|
* @extends Error
|
|
1430
1430
|
* @description Represents a failure of an expectation evaluated with
|
|
1431
1431
|
* {@link throwUnless}. Properties of this error are a subset of the
|
|
1432
|
-
* properties of {@link
|
|
1432
|
+
* properties of {@link ExpectationResult} and have the same values.
|
|
1433
|
+
*
|
|
1434
|
+
* Note: The expected and actual properties are deprecated and may be removed
|
|
1435
|
+
* in a future release. In many Jasmine configurations they are passed
|
|
1436
|
+
* through JSON serialization and deserialization, which is inherently
|
|
1437
|
+
* lossy. In such cases, the expected and actual values may be placeholders
|
|
1438
|
+
* or approximations of the original objects.
|
|
1439
|
+
*
|
|
1433
1440
|
* @property {String} matcherName - The name of the matcher that was executed for this expectation.
|
|
1434
1441
|
* @property {String} message - The failure message for the expectation.
|
|
1435
1442
|
* @property {Boolean} passed - Whether the expectation passed or failed.
|
|
1436
|
-
* @property {Object} expected - If the expectation failed, what was the expected value.
|
|
1437
|
-
* @property {Object} actual - If the expectation failed, what actual value was produced.
|
|
1443
|
+
* @property {Object} expected - Deprecated. If the expectation failed, what was the expected value.
|
|
1444
|
+
* @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced.
|
|
1438
1445
|
*/
|
|
1439
1446
|
const error = new Error(result.message);
|
|
1440
1447
|
error.passed = result.passed;
|
|
@@ -2430,7 +2437,9 @@ getJasmineRequireObj().MapContaining = function(j$) {
|
|
|
2430
2437
|
}
|
|
2431
2438
|
|
|
2432
2439
|
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
|
2433
|
-
if (!j$.isMap(other))
|
|
2440
|
+
if (!j$.isMap(other)) {
|
|
2441
|
+
return false;
|
|
2442
|
+
}
|
|
2434
2443
|
|
|
2435
2444
|
for (const [key, value] of this.sample) {
|
|
2436
2445
|
// for each key/value pair in `sample`
|
|
@@ -2569,7 +2578,9 @@ getJasmineRequireObj().SetContaining = function(j$) {
|
|
|
2569
2578
|
}
|
|
2570
2579
|
|
|
2571
2580
|
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
|
2572
|
-
if (!j$.isSet(other))
|
|
2581
|
+
if (!j$.isSet(other)) {
|
|
2582
|
+
return false;
|
|
2583
|
+
}
|
|
2573
2584
|
|
|
2574
2585
|
for (const item of this.sample) {
|
|
2575
2586
|
// for each item in `sample` there should be at least one matching item in `other`
|
|
@@ -2663,13 +2674,21 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|
|
2663
2674
|
const exceptionFormatter = new j$.ExceptionFormatter();
|
|
2664
2675
|
|
|
2665
2676
|
/**
|
|
2666
|
-
*
|
|
2677
|
+
* Describes the result of evaluating an expectation
|
|
2678
|
+
*
|
|
2679
|
+
* Note: The expected and actual properties are deprecated and may be removed
|
|
2680
|
+
* in a future release. In many Jasmine configurations they are passed
|
|
2681
|
+
* through JSON serialization and deserialization, which is inherently
|
|
2682
|
+
* lossy. In such cases, the expected and actual values may be placeholders
|
|
2683
|
+
* or approximations of the original objects.
|
|
2684
|
+
*
|
|
2685
|
+
* @typedef ExpectationResult
|
|
2667
2686
|
* @property {String} matcherName - The name of the matcher that was executed for this expectation.
|
|
2668
2687
|
* @property {String} message - The failure message for the expectation.
|
|
2669
2688
|
* @property {String} stack - The stack trace for the failure if available.
|
|
2670
2689
|
* @property {Boolean} passed - Whether the expectation passed or failed.
|
|
2671
|
-
* @property {Object} expected - If the expectation failed, what was the expected value.
|
|
2672
|
-
* @property {Object} actual - If the expectation failed, what actual value was produced.
|
|
2690
|
+
* @property {Object} expected - Deprecated. If the expectation failed, what was the expected value.
|
|
2691
|
+
* @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced.
|
|
2673
2692
|
* @property {String|undefined} globalErrorType - The type of an error that
|
|
2674
2693
|
* is reported on the top suite. Valid values are undefined, "afterAll",
|
|
2675
2694
|
* "load", "lateExpectation", and "lateError".
|
|
@@ -2876,7 +2895,8 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
|
2876
2895
|
const maxInlineCallCount = 10;
|
|
2877
2896
|
|
|
2878
2897
|
function browserQueueMicrotaskImpl(global) {
|
|
2879
|
-
const
|
|
2898
|
+
const unclampedSetTimeout = getUnclampedSetTimeout(global);
|
|
2899
|
+
const { queueMicrotask } = global;
|
|
2880
2900
|
let currentCallCount = 0;
|
|
2881
2901
|
return function clearStack(fn) {
|
|
2882
2902
|
currentCallCount++;
|
|
@@ -2885,7 +2905,7 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
|
2885
2905
|
queueMicrotask(fn);
|
|
2886
2906
|
} else {
|
|
2887
2907
|
currentCallCount = 0;
|
|
2888
|
-
|
|
2908
|
+
unclampedSetTimeout(fn);
|
|
2889
2909
|
}
|
|
2890
2910
|
};
|
|
2891
2911
|
}
|
|
@@ -2899,6 +2919,37 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
|
2899
2919
|
}
|
|
2900
2920
|
|
|
2901
2921
|
function messageChannelImpl(global) {
|
|
2922
|
+
const { setTimeout } = global;
|
|
2923
|
+
const postMessage = getPostMessage(global);
|
|
2924
|
+
|
|
2925
|
+
let currentCallCount = 0;
|
|
2926
|
+
return function clearStack(fn) {
|
|
2927
|
+
currentCallCount++;
|
|
2928
|
+
|
|
2929
|
+
if (currentCallCount < maxInlineCallCount) {
|
|
2930
|
+
postMessage(fn);
|
|
2931
|
+
} else {
|
|
2932
|
+
currentCallCount = 0;
|
|
2933
|
+
setTimeout(fn);
|
|
2934
|
+
}
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
function getUnclampedSetTimeout(global) {
|
|
2939
|
+
const { setTimeout } = global;
|
|
2940
|
+
if (j$.util.isUndefined(global.MessageChannel)) {
|
|
2941
|
+
return setTimeout;
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
const postMessage = getPostMessage(global);
|
|
2945
|
+
return function unclampedSetTimeout(fn) {
|
|
2946
|
+
postMessage(function() {
|
|
2947
|
+
setTimeout(fn);
|
|
2948
|
+
});
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
function getPostMessage(global) {
|
|
2902
2953
|
const { MessageChannel, setTimeout } = global;
|
|
2903
2954
|
const channel = new MessageChannel();
|
|
2904
2955
|
let head = {};
|
|
@@ -2922,17 +2973,9 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
|
2922
2973
|
}
|
|
2923
2974
|
};
|
|
2924
2975
|
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
if (currentCallCount < maxInlineCallCount) {
|
|
2930
|
-
tail = tail.next = { task: fn };
|
|
2931
|
-
channel.port2.postMessage(0);
|
|
2932
|
-
} else {
|
|
2933
|
-
currentCallCount = 0;
|
|
2934
|
-
setTimeout(fn);
|
|
2935
|
-
}
|
|
2976
|
+
return function postMessage(fn) {
|
|
2977
|
+
tail = tail.next = { task: fn };
|
|
2978
|
+
channel.port2.postMessage(0);
|
|
2936
2979
|
};
|
|
2937
2980
|
}
|
|
2938
2981
|
|
|
@@ -2942,20 +2985,25 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
|
2942
2985
|
global.process.versions &&
|
|
2943
2986
|
typeof global.process.versions.node === 'string';
|
|
2944
2987
|
|
|
2945
|
-
|
|
2988
|
+
// Windows builds of WebKit have a fairly generic user agent string when no application name is provided:
|
|
2989
|
+
// e.g. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/605.1.15 (KHTML, like Gecko)"
|
|
2990
|
+
const SAFARI_OR_WIN_WEBKIT =
|
|
2946
2991
|
global.navigator &&
|
|
2947
|
-
|
|
2992
|
+
/(^((?!chrome|android).)*safari)|(Win64; x64\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)$)/i.test(
|
|
2993
|
+
global.navigator.userAgent
|
|
2994
|
+
);
|
|
2948
2995
|
|
|
2949
2996
|
if (NODE_JS) {
|
|
2950
2997
|
// Unlike browsers, Node doesn't require us to do a periodic setTimeout
|
|
2951
2998
|
// so we avoid the overhead.
|
|
2952
2999
|
return nodeQueueMicrotaskImpl(global);
|
|
2953
3000
|
} else if (
|
|
2954
|
-
|
|
3001
|
+
SAFARI_OR_WIN_WEBKIT ||
|
|
2955
3002
|
j$.util.isUndefined(global.MessageChannel) /* tests */
|
|
2956
3003
|
) {
|
|
2957
|
-
// queueMicrotask is dramatically faster than MessageChannel in Safari
|
|
2958
|
-
//
|
|
3004
|
+
// queueMicrotask is dramatically faster than MessageChannel in Safari
|
|
3005
|
+
// and other WebKit-based browsers, such as the one distributed by Playwright
|
|
3006
|
+
// to test Safari-like behavior on Windows.
|
|
2959
3007
|
// Some of our own integration tests provide a mock queueMicrotask in all
|
|
2960
3008
|
// environments because it's simpler to mock than MessageChannel.
|
|
2961
3009
|
return browserQueueMicrotaskImpl(global);
|
|
@@ -6650,7 +6698,10 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) {
|
|
|
6650
6698
|
let hasSpy = false;
|
|
6651
6699
|
const calledSpies = [];
|
|
6652
6700
|
for (const spy of Object.values(actual)) {
|
|
6653
|
-
if (!j$.isSpy(spy))
|
|
6701
|
+
if (!j$.isSpy(spy)) {
|
|
6702
|
+
continue;
|
|
6703
|
+
}
|
|
6704
|
+
|
|
6654
6705
|
hasSpy = true;
|
|
6655
6706
|
|
|
6656
6707
|
if (spy.calls.any()) {
|
|
@@ -8051,6 +8102,32 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|
|
8051
8102
|
};
|
|
8052
8103
|
|
|
8053
8104
|
getJasmineRequireObj().reporterEvents = function() {
|
|
8105
|
+
/**
|
|
8106
|
+
* Used to tell Jasmine what optional or uncommonly implemented features
|
|
8107
|
+
* the reporter supports. If not specified, the defaults described in
|
|
8108
|
+
* {@link ReporterCapabilities} will apply.
|
|
8109
|
+
* @name Reporter#reporterCapabilities
|
|
8110
|
+
* @type ReporterCapabilities | undefined
|
|
8111
|
+
* @since 5.0
|
|
8112
|
+
*/
|
|
8113
|
+
/**
|
|
8114
|
+
* Used to tell Jasmine what optional or uncommonly implemented features
|
|
8115
|
+
* the reporter supports.
|
|
8116
|
+
* @interface ReporterCapabilities
|
|
8117
|
+
* @see Reporter#reporterCapabilities
|
|
8118
|
+
* @since 5.0
|
|
8119
|
+
*/
|
|
8120
|
+
/**
|
|
8121
|
+
* Indicates whether the reporter supports parallel execution. Jasmine will
|
|
8122
|
+
* not allow parallel execution unless all reporters that are in use set this
|
|
8123
|
+
* capability to true.
|
|
8124
|
+
* @name ReporterCapabilities#parallel
|
|
8125
|
+
* @type boolean | undefined
|
|
8126
|
+
* @default false
|
|
8127
|
+
* @see running_specs_in_parallel
|
|
8128
|
+
* @since 5.0
|
|
8129
|
+
*/
|
|
8130
|
+
|
|
8054
8131
|
const events = [
|
|
8055
8132
|
/**
|
|
8056
8133
|
* `jasmineStarted` is called after all of the specs have been loaded, but just before execution starts.
|
|
@@ -8967,8 +9044,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
|
|
8967
9044
|
* @property {String} incompleteCode - Machine-readable explanation of why the suite was incomplete: 'focused', 'noSpecsFound', or undefined.
|
|
8968
9045
|
* @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.
|
|
8969
9046
|
* @property {Int} numWorkers - Number of parallel workers. Note that this property is only present when Jasmine is run in parallel mode.
|
|
8970
|
-
* @property {
|
|
8971
|
-
* @property {
|
|
9047
|
+
* @property {ExpectationResult[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
|
9048
|
+
* @property {ExpectationResult[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
|
8972
9049
|
* @since 2.4.0
|
|
8973
9050
|
*/
|
|
8974
9051
|
const jasmineDoneInfo = {
|
|
@@ -9449,6 +9526,16 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|
|
9449
9526
|
|
|
9450
9527
|
obj[methodName] = spiedMethod;
|
|
9451
9528
|
|
|
9529
|
+
// Check if setting the property actually worked. Some objects, such as
|
|
9530
|
+
// localStorage in Firefox and later Safari versions, have no-op setters.
|
|
9531
|
+
if (obj[methodName] !== spiedMethod) {
|
|
9532
|
+
throw new Error(
|
|
9533
|
+
j$.formatErrorMsg('<spyOn>')(
|
|
9534
|
+
`Can't spy on ${methodName} because assigning to it had no effect`
|
|
9535
|
+
)
|
|
9536
|
+
);
|
|
9537
|
+
}
|
|
9538
|
+
|
|
9452
9539
|
return spiedMethod;
|
|
9453
9540
|
};
|
|
9454
9541
|
|
|
@@ -9802,9 +9889,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
|
9802
9889
|
|
|
9803
9890
|
getJasmineRequireObj().StackTrace = function(j$) {
|
|
9804
9891
|
function StackTrace(error) {
|
|
9805
|
-
let lines = error.stack.split('\n')
|
|
9806
|
-
return line !== '';
|
|
9807
|
-
});
|
|
9892
|
+
let lines = error.stack.split('\n');
|
|
9808
9893
|
|
|
9809
9894
|
const extractResult = extractMessage(error.message, lines);
|
|
9810
9895
|
|
|
@@ -9813,6 +9898,10 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|
|
9813
9898
|
lines = extractResult.remainder;
|
|
9814
9899
|
}
|
|
9815
9900
|
|
|
9901
|
+
lines = lines.filter(function(line) {
|
|
9902
|
+
return line !== '';
|
|
9903
|
+
});
|
|
9904
|
+
|
|
9816
9905
|
const parseResult = tryParseFrames(lines);
|
|
9817
9906
|
this.frames = parseResult.frames;
|
|
9818
9907
|
this.style = parseResult.style;
|
|
@@ -10037,8 +10126,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
|
10037
10126
|
* @property {String} fullName - The full description including all ancestors of this suite.
|
|
10038
10127
|
* @property {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe().
|
|
10039
10128
|
* @property {String} filename - The name of the file the suite was defined in.
|
|
10040
|
-
* @property {
|
|
10041
|
-
* @property {
|
|
10129
|
+
* @property {ExpectationResult[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
|
10130
|
+
* @property {ExpectationResult[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
|
10042
10131
|
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
|
10043
10132
|
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
|
10044
10133
|
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
|
@@ -10910,5 +10999,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
|
|
10910
10999
|
};
|
|
10911
11000
|
|
|
10912
11001
|
getJasmineRequireObj().version = function() {
|
|
10913
|
-
return '5.
|
|
11002
|
+
return '5.4.0';
|
|
10914
11003
|
};
|