From 7fbe86848706f4d0686d4b971b7ea3dc9befc436 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Wed, 3 Jul 2024 10:49:15 -0700 Subject: [PATCH] Made asymmetric equality testers more discoverable --- Rakefile | 23 +- _api/edge/AsymmetricEqualityTester.html | 4 +- _api/edge/Clock.html | 2 +- _api/edge/Configuration.html | 2 +- _api/edge/Env.html | 2 +- _api/edge/MatchersUtil.html | 2 +- _api/edge/ParallelReportDispatcher.html | 2 +- _api/edge/Reporter.html | 2 +- _api/edge/Spec.html | 2 +- _api/edge/Spy.html | 2 +- _api/edge/SpyStrategy.html | 2 +- _api/edge/Spy_calls.html | 2 +- _api/edge/Suite.html | 2 +- _api/edge/ThrowUnlessFailure.html | 2 +- _api/edge/Timer.html | 2 +- _api/edge/asymmetricEqualityTesters.html | 1795 ++++++++++++++++++ _api/edge/async-matchers.html | 2 +- _api/edge/global.html | 2 +- _api/edge/index.html | 2 +- _api/edge/jasmine.html | 2198 +++------------------- _api/edge/jsApiReporter.html | 2 +- _api/edge/matchers.html | 2 +- _api/edge/module-jasmine-core.html | 2 +- _jsdoc_plugins/emitted_name.js | 34 + jsdoc-conf-browser-runner.json | 3 +- jsdoc-conf-core.json | 3 +- jsdoc-conf-npm.json | 3 +- 27 files changed, 2144 insertions(+), 1957 deletions(-) create mode 100644 _api/edge/asymmetricEqualityTesters.html create mode 100644 _jsdoc_plugins/emitted_name.js diff --git a/Rakefile b/Rakefile index 80339daf..a5a26318 100644 --- a/Rakefile +++ b/Rakefile @@ -20,13 +20,24 @@ def download_core_file(file_name) `curl -L 'https://raw.github.com/jasmine/jasmine/main/lib/#{file_name}' > .current_version/#{File.basename(file_name)}` end +# Usage: +# rake update_edge_jasmine to pull from github +# rake 'update_edge_jasmine[../jasmine]' to pull from local dir ../jasmine desc "update jasmine-core for edge docs" -task :update_edge_jasmine => ['.current_version'] do - download_core_file('jasmine-core/jasmine.js') - download_core_file('jasmine-core.js') - download_core_file('jasmine-core/jasmine-html.js') - download_core_file('jasmine-core/boot0.js') - download_core_file('jasmine-core/boot1.js') +task :update_edge_jasmine, [:path] => ['.current_version'] do |t, args| + if args.path then + system('cp', "#{args.path}/lib/jasmine-core/jasmine.js", '.current_version/') + system('cp', "#{args.path}/lib/jasmine-core.js", '.current_version/') + system('cp', "#{args.path}/lib/jasmine-core/jasmine-html.js", '.current_version/') + system('cp', "#{args.path}/lib/jasmine-core/boot0.js", '.current_version/') + system('cp', "#{args.path}/lib/jasmine-core/boot1.js", '.current_version/') + else + download_core_file('jasmine-core/jasmine.js') + download_core_file('jasmine-core.js') + download_core_file('jasmine-core/jasmine-html.js') + download_core_file('jasmine-core/boot0.js') + download_core_file('jasmine-core/boot1.js') + end end def download_browser_runner_file(file_name) diff --git a/_api/edge/AsymmetricEqualityTester.html b/_api/edge/AsymmetricEqualityTester.html index be8a9388..7ead93d2 100644 --- a/_api/edge/AsymmetricEqualityTester.html +++ b/_api/edge/AsymmetricEqualityTester.html @@ -6,7 +6,7 @@
@@ -26,7 +26,7 @@

AsymmetricEqualityTester

An asymmetric equality tester is an object that can match multiple objects. Examples include jasmine.any() and jasmine.stringMatching(). Jasmine includes a number of built-in asymmetric equality testers, such as -jasmine.objectContaining. User-defined asymmetric equality testers are +jasmine.objectContaining. User-defined asymmetric equality testers are also supported.

Asymmetric equality testers work with any matcher, including user-defined custom matchers, that uses MatchersUtil#equals or diff --git a/_api/edge/Clock.html b/_api/edge/Clock.html index 9cc70b9d..eea85f70 100644 --- a/_api/edge/Clock.html +++ b/_api/edge/Clock.html @@ -6,7 +6,7 @@

diff --git a/_api/edge/Configuration.html b/_api/edge/Configuration.html index e931e8af..0782ca85 100644 --- a/_api/edge/Configuration.html +++ b/_api/edge/Configuration.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Env.html b/_api/edge/Env.html index d92472d8..ea5c69be 100644 --- a/_api/edge/Env.html +++ b/_api/edge/Env.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/MatchersUtil.html b/_api/edge/MatchersUtil.html index ef35fefa..15af68cd 100644 --- a/_api/edge/MatchersUtil.html +++ b/_api/edge/MatchersUtil.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/ParallelReportDispatcher.html b/_api/edge/ParallelReportDispatcher.html index edb9821b..1b448b6c 100644 --- a/_api/edge/ParallelReportDispatcher.html +++ b/_api/edge/ParallelReportDispatcher.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Reporter.html b/_api/edge/Reporter.html index 6de77f6d..685c5a54 100644 --- a/_api/edge/Reporter.html +++ b/_api/edge/Reporter.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Spec.html b/_api/edge/Spec.html index ddea6705..d22f80f9 100644 --- a/_api/edge/Spec.html +++ b/_api/edge/Spec.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Spy.html b/_api/edge/Spy.html index 0ec5d8ad..373a6c99 100644 --- a/_api/edge/Spy.html +++ b/_api/edge/Spy.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/SpyStrategy.html b/_api/edge/SpyStrategy.html index ff0cde23..d74aa7c6 100644 --- a/_api/edge/SpyStrategy.html +++ b/_api/edge/SpyStrategy.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Spy_calls.html b/_api/edge/Spy_calls.html index 84ee2993..bbb6684c 100644 --- a/_api/edge/Spy_calls.html +++ b/_api/edge/Spy_calls.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Suite.html b/_api/edge/Suite.html index 4312105f..072c983e 100644 --- a/_api/edge/Suite.html +++ b/_api/edge/Suite.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/ThrowUnlessFailure.html b/_api/edge/ThrowUnlessFailure.html index c969ed14..9a49266b 100644 --- a/_api/edge/ThrowUnlessFailure.html +++ b/_api/edge/ThrowUnlessFailure.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/Timer.html b/_api/edge/Timer.html index 2296273e..7360f7b4 100644 --- a/_api/edge/Timer.html +++ b/_api/edge/Timer.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/asymmetricEqualityTesters.html b/_api/edge/asymmetricEqualityTesters.html new file mode 100644 index 00000000..fdc83a88 --- /dev/null +++ b/_api/edge/asymmetricEqualityTesters.html @@ -0,0 +1,1795 @@ +--- +layout: default +title: "Namespace: asymmetricEqualityTesters" +prettify: true +--- + +
+ + +
+

Namespace: asymmetricEqualityTesters

+ + + + + + +
+ +
+ +

asymmetricEqualityTesters

+ + +
+ +
+
+ + +

Asymmetric equality testers allow for +non-exact matching in matchers that use Jasmine's deep value equality +semantics, such as toEqual, +toContain, and +toHaveBeenCalledWith.

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +

Example

+ +
const someComplexObject = {
+  foo: 'bar',
+  baz: 'a string that contains "something"',
+  qux: 'whatever'
+};
+// Passes.
+expect(someComplexObject).toEqual(jasmine.objectContaining({
+  foo: 'bar',
+  baz: jasmine.stringContaining('something')
+});
+ + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

(static) jasmine.any(clazz)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is an instance of the specified class/constructor.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
clazz + + +Constructor + + + +

The constructor to check against.

+ + + + + + +
+ + + + +
Since:
+
  • 1.3.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.anything()

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is not null and not undefined.

+
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 2.2.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.arrayContaining(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value is an Array that contains at least the elements in the sample.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Array + + + +
+ + + + + + +
+ + + + +
Since:
+
  • 2.2.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.arrayWithExactContents(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value is an Array that contains all of the elements in the sample in +any order.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Array + + + +
+ + + + + + +
+ + + + +
Since:
+
  • 2.8.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.empty()

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is empty.

+
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 3.1.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.falsy()

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is null, undefined, 0, false or anything +falsy.

+
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 3.1.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.is(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that passes if the actual value is +the same as the sample as determined by the === operator.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Object + + + +

The value to compare the actual to.

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.mapContaining(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if every +key/value pair in the sample passes the deep equality comparison +with at least one key/value pair in the actual value being compared

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Map + + + +

The subset of items that must be in the actual.

+ + + + + + +
+ + + + +
Since:
+
  • 3.5.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.notEmpty()

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is not empty.

+
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 3.1.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.objectContaining(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared contains at least the specified keys and values.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Object + + + +

The subset of properties that must be in the actual.

+ + + + + + +
+ + + + +
Since:
+
  • 1.3.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.setContaining(sample)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if every item +in the sample passes the deep equality comparison +with at least one item in the actual value being compared

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sample + + +Set + + + +

The subset of items that must be in the actual.

+ + + + + + +
+ + + + +
Since:
+
  • 3.5.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.stringContaining(expected)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value is a String that contains the specified String.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
expected + + +String + + + +
+ + + + + + +
+ + + + +
Since:
+
  • 3.10.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.stringMatching(expected)

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value is a String that matches the RegExp or String.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
expected + + +RegExp +| + +String + + + +
+ + + + + + +
+ + + + +
Since:
+
  • 2.2.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) jasmine.truthy()

+ + + + + + +
+

Get an AsymmetricEqualityTester that will succeed if the actual +value being compared is true or anything truthy.

+
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 3.1.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ Documentation generated by JSDoc. +
+
\ No newline at end of file diff --git a/_api/edge/async-matchers.html b/_api/edge/async-matchers.html index 66f39fed..38a2b9d3 100644 --- a/_api/edge/async-matchers.html +++ b/_api/edge/async-matchers.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/global.html b/_api/edge/global.html index 1644256b..3710bcda 100644 --- a/_api/edge/global.html +++ b/_api/edge/global.html @@ -7,7 +7,7 @@
diff --git a/_api/edge/index.html b/_api/edge/index.html index 35744bad..00a0eaac 100644 --- a/_api/edge/index.html +++ b/_api/edge/index.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/jasmine.html b/_api/edge/jasmine.html index e94a74dc..7ebe1f41 100644 --- a/_api/edge/jasmine.html +++ b/_api/edge/jasmine.html @@ -6,7 +6,7 @@
@@ -30,6 +30,12 @@

jasmine

+

Members of the jasmine global.

+

Note: The members of the +asymmetricEqualityTesters namespace +are also accessed via the jasmine global, but due to jsdoc limitations +they are not listed here.

+ @@ -1104,7 +1110,7 @@
Parameters:
-

(static) any(clazz)

+

(static) clock() → {Clock}

@@ -1112,8 +1118,7 @@

(static) any -

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is an instance of the specified class/constructor.

+

Get the currently booted mock {Clock} for this Jasmine environment.

@@ -1124,55 +1129,6 @@

(static) anyParameters:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
clazz - - -Constructor - - - -

The constructor to check against.

- - @@ -1183,7 +1139,7 @@
Parameters:
Since:
-
  • 1.3.0
+
  • 2.0.0
@@ -1229,93 +1185,24 @@
Parameters:
- - - - +
Returns:
- - - - - -

(static) anything()

- - - +
+
+ Type +
+
+ +Clock -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is not null and not undefined.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 2.2.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - +
- - - - - - - - - - - - - - + @@ -1327,7 +1214,7 @@

(static) any -

(static) arrayContaining(sample)

+

(static) createSpy(nameopt, originalFnopt) → {Spy}

@@ -1335,8 +1222,7 @@

(static) -

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value is an Array that contains at least the elements in the sample.

+

Create a bare Spy object. This won't be installed anywhere and will not have any implementation behind it.

@@ -1360,6 +1246,8 @@
Parameters:
Type + Attributes + @@ -1372,23 +1260,70 @@
Parameters:
- sample + name + + + + + +String + + + + + + + + + <optional>
+ + + + + + + + + + +

Name to give the spy. This will be displayed in failure messages.

+ + + + + + + originalFn -Array +function + + + <optional>
+ + + + + + + - +

The "real" function. This will +be used for subsequent calls to the spy after you call +mySpy.and.callThrough(). In most cases you should omit this parameter. +The usual way to supply an original function is to call spyOn +instead of createSpy.

@@ -1406,7 +1341,7 @@
Parameters:
Since:
-
  • 2.2.0
+
  • 1.3.0
@@ -1452,6 +1387,24 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +Spy + + +
+
+ + @@ -1463,7 +1416,7 @@
Parameters:
-

(static) arrayWithExactContents(sample)

+

(static) createSpyObj(baseNameopt, methodNames, propertyNamesopt) → {Object}

@@ -1471,8 +1424,7 @@

(stat
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value is an Array that contains all of the elements in the sample in any order.

+

Create an object with multiple Spys as its members.

@@ -1496,6 +1448,8 @@
Parameters:
Type + Attributes + @@ -1508,114 +1462,108 @@
Parameters:
- sample + baseName -Array +String + + + <optional>
+ + + + + + + - +

Base name for the spies in the object.

- - - + + + methodNames + + + + +Array.<String> +| +Object -
+ + - + + + - -
Since:
-
  • 2.8.0
- + - + + + - + - - - - - - - - - - - - - - - - - - - - - +

Array of method names to create spies for, or Object whose keys will be method names and values the returnValue.

+ -
- - - - - - - - - - - - + + + propertyNames + + + + +Array.<String> +| +Object + + + + + + <optional>
+ + - + + - + - -

(static) clock() → {Clock}

- +

Array of property names to create spies for, or Object whose keys will be propertynames and values the returnValue.

+ - - - -
-

Get the currently booted mock {Clock} for this Jasmine environment.

-
- - - - - - - + + @@ -1628,7 +1576,7 @@

(static) clock<
Since:
-
  • 2.0.0
+
  • 1.3.0
@@ -1685,7 +1633,7 @@

Returns:
-Clock +Object
@@ -1703,7 +1651,7 @@
Returns:
-

(static) createSpy(nameopt, originalFnopt) → {Spy}

+

(static) debugLog(msg)

@@ -1711,7 +1659,11 @@

(static) cr
-

Create a bare Spy object. This won't be installed anywhere and will not have any implementation behind it.

+

Logs a message for use in debugging. If the spec fails, trace messages +will be included in the result passed to the +reporter's specDone method.

+

This method should be called only when a spec (including any associated +beforeEach or afterEach functions) is running.

@@ -1735,8 +1687,6 @@

Parameters:
Type - Attributes - @@ -1749,7 +1699,7 @@
Parameters:
- name + msg @@ -1762,57 +1712,10 @@
Parameters:
- - - <optional>
- - - - - - - - - - -

Name to give the spy. This will be displayed in failure messages.

- - - - - - - originalFn - - - - - -function - - - - - - - - - <optional>
- - - - - - - -

The "real" function. This will -be used for subsequent calls to the spy after you call -mySpy.and.callThrough(). In most cases you should omit this parameter. -The usual way to supply an original function is to call spyOn -instead of createSpy.

+

The message to log

@@ -1830,7 +1733,7 @@
Parameters:
Since:
-
  • 1.3.0
+
  • 4.0.0
@@ -1876,24 +1779,6 @@
Parameters:
-
Returns:
- - - - -
-
- Type -
-
- -Spy - - -
-
- - @@ -1905,1509 +1790,23 @@
Returns:
-

(static) createSpyObj(baseNameopt, methodNames, propertyNamesopt) → {Object}

- - - - - - -
-

Create an object with multiple Spys as its members.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - +

(static) getEnv() → {Env}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseName - - -String - - - - - - <optional>
- - - - - -

Base name for the spies in the object.

methodNames - - -Array.<String> -| - -Object - - - - - - - - - -

Array of method names to create spies for, or Object whose keys will be method names and values the returnValue.

propertyNames - - -Array.<String> -| - -Object - - - - - - <optional>
- - - - - -

Array of property names to create spies for, or Object whose keys will be propertynames and values the returnValue.

- - - - - - -
- - - - -
Since:
-
  • 1.3.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -Object - - -
-
- - - - - - - - - - - - - -

(static) debugLog(msg)

- - - - - - -
-

Logs a message for use in debugging. If the spec fails, trace messages -will be included in the result passed to the -reporter's specDone method.

-

This method should be called only when a spec (including any associated -beforeEach or afterEach functions) is running.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
msg - - -String - - - -

The message to log

- - - - - - -
- - - - -
Since:
-
  • 4.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) empty()

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is empty.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 3.1.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) falsy()

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is null, undefined, 0, false or anything falsey.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 3.1.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) getEnv() → {Env}

- - - - - - -
-

Get the currently booted Jasmine Environment.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 1.3.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -Env - - -
-
- - - - - - - - - - - - - -

(static) is(sample)

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher -that passes if the actual value is the same as the sample as determined -by the === operator.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sample - - -Object - - - -

The value to compare the actual to.

- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) isSpy(putativeSpy) → {Boolean}

- - - - - - -
-

Determines whether the provided function is a Jasmine spy.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
putativeSpy - - -function - - - -

The function to check.

- - - - - - -
- - - - -
Since:
-
  • 2.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -Boolean - - -
-
- - - - - - - - - - - - - -

(static) mapContaining(sample)

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if every key/value pair in the sample passes the deep equality comparison -with at least one key/value pair in the actual value being compared

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sample - - -Map - - - -

The subset of items that must be in the actual.

- - - - - - -
- - - - -
Since:
-
  • 3.5.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) notEmpty()

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is not empty.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 3.1.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) objectContaining(sample)

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared contains at least the keys and values.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sample - - -Object - - - -

The subset of properties that must be in the actual.

- - - - - - -
- - - - -
Since:
-
  • 1.3.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) setContaining(sample)

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if every item in the sample passes the deep equality comparison -with at least one item in the actual value being compared

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sample - - -Set - - - -

The subset of items that must be in the actual.

- - - - - - -
- - - - -
Since:
-
  • 3.5.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

(static) setDefaultSpyStrategy(defaultStrategyFn)

- - - - - - -
-

Set the default spy strategy for the current scope of specs.

-

Note: This is only callable from within a beforeEach, it, or beforeAll.

-
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - +
+

Get the currently booted Jasmine Environment.

+
- - - - - - - -
NameTypeDescription
defaultStrategyFn - - -function - -

a function that assigns a strategy

@@ -3419,6 +1818,9 @@
Parameters:
+
Since:
+
  • 1.3.0
+ @@ -3463,15 +1865,26 @@
Parameters:
+
Returns:
+ + + +
+
+ Type +
+
+ +Env +
+
-
Example
-
beforeEach(function() {
-  jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
-});
+ + @@ -3481,7 +1894,7 @@
Example
-

(async, static) spyOnGlobalErrorsAsync(fn)

+

(static) isSpy(putativeSpy) → {Boolean}

@@ -3489,34 +1902,7 @@

(asyn
-

Replaces Jasmine's global error handling with a spy. This prevents Jasmine -from treating uncaught exceptions and unhandled promise rejections -as spec failures and allows them to be inspected using the spy's -calls property and related matchers such as -toHaveBeenCalledWith.

-

After installing the spy, spyOnGlobalErrorsAsync immediately calls its -argument, which must be an async or promise-returning function. The spy -will be passed as the first argument to that callback. Normal error -handling will be restored when the promise returned from the callback is -settled.

-

When the JavaScript runtime reports an uncaught error or unhandled rejection, -the spy will be called with a single parameter representing Jasmine's best -effort at describing the error. This parameter may be of any type, because -JavaScript allows anything to be thrown or used as the reason for a -rejected promise, but Error instances and strings are most common.

-

Note: The JavaScript runtime may deliver uncaught error events and unhandled -rejection events asynchronously, especially in browsers. If the event -occurs after the promise returned from the callback is settled, it won't -be routed to the spy even if the underlying error occurred previously. -It's up to you to ensure that all of the error/rejection events that you -want to handle have occurred before you resolve the promise returned from -the callback.

-

You must ensure that the it/beforeEach/etc fn that called -spyOnGlobalErrorsAsync does not signal completion until after the -promise returned by spyOnGlobalErrorsAsync is resolved. Normally this is -done by awaiting the returned promise. Leaving the global error spy -installed after the it/beforeEach/etc fn that installed it signals -completion is likely to cause problems and is not supported.

+

Determines whether the provided function is a Jasmine spy.

@@ -3552,13 +1938,13 @@
Parameters:
- fn + putativeSpy -AsyncFunction +function @@ -3568,7 +1954,7 @@
Parameters:
-

A function to run, during which the global error spy will be effective

+

The function to check.

@@ -3585,6 +1971,9 @@
Parameters:
+
Since:
+
  • 2.0.0
+ @@ -3629,24 +2018,26 @@
Parameters:
+
Returns:
+ + + +
+
+ Type +
+
+ +Boolean +
+
-
Example
-
it('demonstrates global error spies', async function() {
-  await jasmine.spyOnGlobalErrorsAsync(async function(globalErrorSpy) {
-    setTimeout(function() {
-      throw new Error('the expected error');
-    });
-    await new Promise(function(resolve) {
-      setTimeout(resolve);
-    });
-    const expected = new Error('the expected error');
-    expect(globalErrorSpy).toHaveBeenCalledWith(expected);
-  });
-});
+ + @@ -3656,7 +2047,7 @@
Example
-

(static) stringContaining(expected)

+

(static) setDefaultSpyStrategy(defaultStrategyFn)

@@ -3664,8 +2055,8 @@

(static) -

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value is a String that contains the specified String.

+

Set the default spy strategy for the current scope of specs.

+

Note: This is only callable from within a beforeEach, it, or beforeAll.

@@ -3701,13 +2092,13 @@
Parameters:
- expected + defaultStrategyFn -String +function @@ -3717,7 +2108,7 @@
Parameters:
- +

a function that assigns a strategy

@@ -3734,9 +2125,6 @@
Parameters:
-
Since:
-
  • 3.10.0
- @@ -3785,6 +2173,13 @@
Parameters:
+
Example
+ +
beforeEach(function() {
+  jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
+});
+ + @@ -3792,7 +2187,7 @@
Parameters:
-

(static) stringMatching(expected)

+

(async, static) spyOnGlobalErrorsAsync(fn)

@@ -3800,8 +2195,34 @@

(static) -

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value is a String that matches the RegExp or String.

+

Replaces Jasmine's global error handling with a spy. This prevents Jasmine +from treating uncaught exceptions and unhandled promise rejections +as spec failures and allows them to be inspected using the spy's +calls property and related matchers such as +toHaveBeenCalledWith.

+

After installing the spy, spyOnGlobalErrorsAsync immediately calls its +argument, which must be an async or promise-returning function. The spy +will be passed as the first argument to that callback. Normal error +handling will be restored when the promise returned from the callback is +settled.

+

When the JavaScript runtime reports an uncaught error or unhandled rejection, +the spy will be called with a single parameter representing Jasmine's best +effort at describing the error. This parameter may be of any type, because +JavaScript allows anything to be thrown or used as the reason for a +rejected promise, but Error instances and strings are most common.

+

Note: The JavaScript runtime may deliver uncaught error events and unhandled +rejection events asynchronously, especially in browsers. If the event +occurs after the promise returned from the callback is settled, it won't +be routed to the spy even if the underlying error occurred previously. +It's up to you to ensure that all of the error/rejection events that you +want to handle have occurred before you resolve the promise returned from +the callback.

+

You must ensure that the it/beforeEach/etc fn that called +spyOnGlobalErrorsAsync does not signal completion until after the +promise returned by spyOnGlobalErrorsAsync is resolved. Normally this is +done by awaiting the returned promise. Leaving the global error spy +installed after the it/beforeEach/etc fn that installed it signals +completion is likely to cause problems and is not supported.

@@ -3837,16 +2258,13 @@
Parameters:
- expected + fn -RegExp -| - -String +AsyncFunction @@ -3856,7 +2274,7 @@
Parameters:
- +

A function to run, during which the global error spy will be effective

@@ -3873,9 +2291,6 @@
Parameters:
-
Since:
-
  • 2.2.0
- @@ -3924,91 +2339,20 @@
Parameters:
- - - - - - - -

(static) truthy()

- - - - - - -
-

Get an AsymmetricEqualityTester, usable in any matcher that uses Jasmine's equality (e.g. toEqual, toContain, or toHaveBeenCalledWith), -that will succeed if the actual value being compared is true or anything truthy.

-
- - - - - - - - - - - - - -
- - - - -
Since:
-
  • 3.1.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Example
-
- - - - - - - - - - - - - - - - - +
it('demonstrates global error spies', async function() {
+  await jasmine.spyOnGlobalErrorsAsync(async function(globalErrorSpy) {
+    setTimeout(function() {
+      throw new Error('the expected error');
+    });
+    await new Promise(function(resolve) {
+      setTimeout(resolve);
+    });
+    const expected = new Error('the expected error');
+    expect(globalErrorSpy).toHaveBeenCalledWith(expected);
+  });
+});
diff --git a/_api/edge/jsApiReporter.html b/_api/edge/jsApiReporter.html index c5b28f92..73342bda 100644 --- a/_api/edge/jsApiReporter.html +++ b/_api/edge/jsApiReporter.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/matchers.html b/_api/edge/matchers.html index 2db37ec0..af818ba7 100644 --- a/_api/edge/matchers.html +++ b/_api/edge/matchers.html @@ -6,7 +6,7 @@
diff --git a/_api/edge/module-jasmine-core.html b/_api/edge/module-jasmine-core.html index 677bc26d..0662195c 100644 --- a/_api/edge/module-jasmine-core.html +++ b/_api/edge/module-jasmine-core.html @@ -6,7 +6,7 @@
diff --git a/_jsdoc_plugins/emitted_name.js b/_jsdoc_plugins/emitted_name.js new file mode 100644 index 00000000..e0598e66 --- /dev/null +++ b/_jsdoc_plugins/emitted_name.js @@ -0,0 +1,34 @@ +var fs = require('fs'); + +/* Adds an emittedName tag to handle situations where there's a mismatch between + the page we want a doclet to be included in and the syntax a caller would use + to access the thing being documented. We currently use this to put the + functions that return asymmetric equality testers on their own page while + still documenting that they're accessed via the jasmine namespace. + + Example jsdoc usage: + @name asymmetricEqualityTesters.setContaining + @emittedName jasmine.setContaining + */ + +exports.handlers = { + newDoclet: function(e) { + const doclet = e.doclet; + + if (doclet.emittedName) { + doclet.name = doclet.emittedName; + } + } +} + +exports.defineTags = function(dictionary) { + dictionary.defineTag('emittedName', { + mustHaveValue: true, + mustNotHaveDescription: true, + canHaveType: false, + canHaveName: false, + onTagged: function(doclet, tag) { + doclet.emittedName = tag.value; + } + }); +}; diff --git a/jsdoc-conf-browser-runner.json b/jsdoc-conf-browser-runner.json index b25e53be..d44c832c 100644 --- a/jsdoc-conf-browser-runner.json +++ b/jsdoc-conf-browser-runner.json @@ -14,7 +14,8 @@ }, "plugins": [ "plugins/markdown", - "_jsdoc_plugins/see_tutorials" + "_jsdoc_plugins/see_tutorials", + "_jsdoc_plugins/emitted_name" ], "templates": { "cleverLinks": true, diff --git a/jsdoc-conf-core.json b/jsdoc-conf-core.json index 0846cdf1..66c73de5 100644 --- a/jsdoc-conf-core.json +++ b/jsdoc-conf-core.json @@ -14,7 +14,8 @@ }, "plugins": [ "plugins/markdown", - "_jsdoc_plugins/see_tutorials" + "_jsdoc_plugins/see_tutorials", + "_jsdoc_plugins/emitted_name" ], "templates": { "cleverLinks": true, diff --git a/jsdoc-conf-npm.json b/jsdoc-conf-npm.json index f0183031..ca139f61 100644 --- a/jsdoc-conf-npm.json +++ b/jsdoc-conf-npm.json @@ -14,7 +14,8 @@ }, "plugins": [ "plugins/markdown", - "_jsdoc_plugins/see_tutorials" + "_jsdoc_plugins/see_tutorials", + "_jsdoc_plugins/emitted_name" ], "templates": { "cleverLinks": true,