Compare commits

..

263 Commits

Author SHA1 Message Date
Steve Gravrock
0ae234dc6e Bump version to 4.0.1 2022-02-21 16:58:32 -08:00
Steve Gravrock
38d102f1d1 Merge branch '3.99.1' into 4.0.1 2022-02-21 16:45:34 -08:00
Steve Gravrock
906f37fe52 Bump version to 3.99.1 2022-02-21 16:30:15 -08:00
Steve Gravrock
4a2b10998a Remove Safari 8 and 9 from CI matrix
These browsers are still nominally supported by Jasmine 3.x, but they no
longer work on Saucelabs.
2022-02-19 14:23:02 -08:00
Steve Gravrock
d8b2efe4d6 Downgrade jasmine-browser-runner for compatibility with IE 2022-02-19 14:21:35 -08:00
Steve Gravrock
9d9e8f0c17 Lint fixes 2022-02-19 12:33:19 -08:00
Steve Gravrock
4059ab7ba6 Don't report a deprecation when a promise is resolved to something
beforeEach(() => somePromiseReturningFn()) is likely a common idiom
and we don't want to treat it as an error.

* Fixes #1958
2022-02-19 12:28:47 -08:00
Steve Gravrock
98c2f019c6 Bump version to 4.0.0 2022-01-01 12:43:29 -08:00
Steve Gravrock
507dad6d87 Set -npm and -browser-runner dev dependencies back to main 2022-01-01 12:10:24 -08:00
Steve Gravrock
6da7a32442 Merge branch '4.0' 2022-01-01 12:00:46 -08:00
Steve Gravrock
58d13570ac Bump version to 3.99.0 2022-01-01 10:47:59 -08:00
Steve Gravrock
005648acd8 Built distribution 2022-01-01 10:46:15 -08:00
Steve Gravrock
ff14c03a40 Test against the latest Node 12 2022-01-01 08:44:28 -08:00
Steve Gravrock
ff848c812a Merge branch 'main' into 4.0 2021-12-31 15:07:03 -08:00
Steve Gravrock
d963be5eec Log a deprecation warning on reentrant calls to Clock#tick
See #1929
2021-12-31 11:38:01 -08:00
Steve Gravrock
8444faab72 Use the clock from jasmineUnderTest in specs 2021-12-31 10:00:14 -08:00
Steve Gravrock
883f400074 Merge branch '4.0' of https://github.com/thw0rted/jasmine into 4.0
* Fixes handling of reentrant calls to `jasmine.clock().tick()`
* Merges #1948 from @thw0rted
* Fixes #1929
2021-12-31 09:50:09 -08:00
Steve Gravrock
3c16caa413 Link to the CONTRIBUTING guide from the PR template 2021-12-31 09:47:46 -08:00
Steve Gravrock
5d0be2e6cf Updated the contributing guide for 4.0
* Moved "Before Submitting a Pull Request" to the top
* Removed discussion of the standard Github PR workflow
  (Contributors who don't know how to create PRs on Github at all can find
  that information elsewhere. For the rest, it's just noise.)
* Misc copy edits
2021-12-31 09:43:46 -08:00
James Bromwell
c56631175f Fix time-travel in delayed function scheduler 2021-12-29 17:50:48 +01:00
Steve Gravrock
cef738966c Updated dev dependencies 2021-12-21 17:51:28 -08:00
Steve Gravrock
5fd0e49ccf Removed unused ejs dev dependency 2021-12-21 17:00:10 -08:00
Steve Gravrock
c431590d65 Fixed reporting of suites that are skipped due to a beforeAll failure 2021-12-20 13:39:24 -08:00
Steve Gravrock
656e6614da Built distribution 2021-12-15 20:36:44 -08:00
Steve Gravrock
24408a16ed Removed initialization of unused Promise config property 2021-12-15 20:34:00 -08:00
Steve Gravrock
ca90c76d12 Merge branch '3.99' into 4.0 2021-12-14 08:27:05 -08:00
Steve Gravrock
57c294b307 Added a migration guide link to multiple done call deprecations 2021-12-14 08:16:06 -08:00
Steve Gravrock
e73eb18753 Test against jasmine-browser-runner 1.0.0-dev 2021-12-13 21:41:09 -08:00
Steve Gravrock
0411b0567d Added a mention of 4.0 migration to the README 2021-12-11 16:13:51 -08:00
Steve Gravrock
30b93ccdbb Updated jsdocs for Env#execute 2021-12-11 15:53:25 -08:00
Steve Gravrock
067b91b3ef Removed IE/PhantomJS support code 2021-12-11 14:57:41 -08:00
Steve Gravrock
0b1385c3d3 Report start and end events for specs/suites that are skipped due to a beforeAll error
This is noisier, but it maintains compatibility with reporters that assume
(quite reasonably) that all specs and suites are either filtered out or
reported.
2021-12-11 12:34:23 -08:00
Steve Gravrock
f1cf6ee419 Resolve the execute() promise to the entire JasmineDoneInfo
This matches jasmine-npm.
2021-12-09 18:18:36 -08:00
Steve Gravrock
b37d989f13 Removed past-EOL Firefox versions 2021-12-07 18:16:00 -08:00
Steve Gravrock
89151d6e64 Dropped Safari 13 from build matrix 2021-12-07 17:04:19 -08:00
Steve Gravrock
75e3e14861 Merge remote-tracking branch 'upstream/safari-15' into 4.0 2021-12-07 17:03:40 -08:00
Steve Gravrock
ce7460d8d4 Fixed stack trace filtering on Safari 15 2021-12-07 16:50:07 -08:00
Steve Gravrock
b8dabf96ff HTML: Include top suite failures in the reported failure count 2021-12-03 08:18:18 -08:00
Steve Gravrock
40fac8b6a2 Renamed the trace feature to debugLog[s]
"trace" was ambiguous and could easily be understood to have something
to do with stack traces.
2021-12-02 14:46:56 -08:00
Steve Gravrock
5eb42d67a7 Added a note about async testing style to contributing guide 2021-12-02 12:40:14 -08:00
Steve Gravrock
d739c23401 Resolve the promise returned by Env#execute to the overall status 2021-12-02 12:40:14 -08:00
Steve Gravrock
42e6c45efa Allow use without creating globals
* Fixes #1235
2021-11-29 20:37:07 -08:00
Steve Gravrock
5942654856 Merge branch '3.99' into 4.0 2021-11-26 13:27:57 -08:00
Steve Gravrock
f3b26a0688 Merge branch 'main' into 3.99 2021-11-26 13:25:14 -08:00
Steve Gravrock
8804ddb8cf Updated boot file lists for the Ruby gem and Python egg
This prevents consumers that rely on those lists (especially the Jasmine
gem and egg) from getting a deprecation warning about boot.js.
2021-11-24 15:38:40 -08:00
Steve Gravrock
439be97c34 Rephrased note about verboseDeprecations 2021-11-24 11:45:32 -08:00
Steve Gravrock
871ba99a30 Allow custom spy strategies to be inherited like other runnable resources 2021-11-17 12:50:16 -08:00
Steve Gravrock
7a685b16f6 Removed duplicate message from errors (incl. matcher failures) on V8 2021-11-16 12:52:07 -08:00
Steve Gravrock
2a049015b0 Use custom equality testers in Spy#withArgs
Fixes #1836.
2021-11-15 18:55:09 -08:00
Steve Gravrock
c48fb0b0e7 Added Firefox 91 (current ESR) to CI matrix 2021-11-14 14:18:06 -08:00
Steve Gravrock
4c47bf6c0b Merge branch '3.10.1' into main 2021-10-22 16:34:57 -07:00
Steve Gravrock
e86a7f00a6 Bump version to 3.10.1 2021-10-22 16:15:54 -07:00
Jan Molak
504ef27899 Fixed result.pendingReason for specs marked with xit. Closes #1939 2021-10-22 14:12:28 -07:00
Steve Gravrock
2a39339755 Merge branch 'fix/pending-reason' of https://github.com/jan-molak/jasmine into main
* Fixes missing pendingReason in pending spec results
	* Fixes #1939
	* Merges #1940 from @jan-molak
2021-10-22 14:09:48 -07:00
Jan Molak
2c440b8e44 Fixed result.pendingReason for specs marked with xit. Closes #1939 2021-10-22 17:58:31 +01:00
Steve Gravrock
8e74529631 Merge branch '3.99' into 4.0 2021-10-15 10:37:51 -07:00
Steve Gravrock
b13329114c Set version to 3.99.0-dev 2021-10-15 10:33:21 -07:00
Steve Gravrock
ab34f272da Merge branch 'main' into 3.99 2021-10-15 10:29:50 -07:00
Steve Gravrock
1af0e62ef7 Revert "Revert "Dogfood the new jasmine-npm completion interface""
This reverts commit 4c043717a9.
2021-10-14 07:07:10 -07:00
Steve Gravrock
572452a15a Added supported environments to 3.10.0 release notes 2021-10-13 16:47:48 -07:00
Steve Gravrock
896412367a Bump version to 3.10.0 2021-10-13 15:46:21 -07:00
Steve Gravrock
503a7409f0 Merge branch 'issue-1854-asyncerror' of https://github.com/AndreWillomitzer/jasmine into main
* Improves error message when an async expectation occurs after the spec
  finishes
* Merges #1937 from @AndreWillomitzer
* Fixes #1854
2021-10-12 17:15:53 -07:00
Steve Gravrock
c1db8f2f82 Clarified deprecation message for this in describes 2021-10-12 15:40:13 -07:00
Andre Willomitzer
bb9175cb66 added additional error msg for delayedExpectation
added matching error msgs in jasmine objects

Ran prettier.

removed indenting, formatted column length < 80
2021-10-12 13:17:24 -04:00
Steve Gravrock
41f5c53959 Consistently identify clenaup fns by a type tag, not position
This was already done for everything except spec cleanup fns, since the
various skip policies need to know the difference between afterEach and
afterAll.
2021-10-11 18:05:57 -07:00
Steve Gravrock
25c3f06839 Run afterAll fns after failure even if stopOnSpecFailure is true
[#160905297]
2021-10-08 14:19:56 -07:00
Steve Gravrock
976928c7ae Set version to 4.0.0-pre.0 2021-10-08 08:48:22 -07:00
Steve Gravrock
36a4ddf433 Revert "Removed jsdoc entry for SpecResult#trace"
This reverts commit 4482355885.
2021-10-07 10:56:52 -07:00
Steve Gravrock
53b1cd37b6 Merge branch '3.99' into 4.0 2021-10-07 10:56:41 -07:00
Steve Gravrock
8cadfbd829 Fixed deprecation warning in spec 2021-10-07 10:51:06 -07:00
Steve Gravrock
86aeb5c88a Merge branch 'main' into 3.99 2021-10-07 10:38:35 -07:00
Steve Gravrock
469b557828 Merge branch 'fix/ie' of https://github.com/nicojs/jasmine into main
* Merges #1936 from @nicojs
2021-10-07 10:17:16 -07:00
Nico Jansen
503715c275 test(ie): refactor promises to callbacks 2021-10-07 10:23:52 +02:00
Steve Gravrock
d4c15b8df4 No longer test Node <12.17 2021-10-06 17:58:28 -07:00
Steve Gravrock
6f0c51260f Depend on the 4.0 branch of -npm 2021-10-06 17:54:54 -07:00
Steve Gravrock
4482355885 Removed jsdoc entry for SpecResult#trace
Deferred to 4.0.
2021-10-06 11:31:29 -07:00
Steve Gravrock
6542364381 Merge branch 'feat/support-multiple-runs' of https://github.com/nicojs/jasmine into main
* Merges #1934 from @nicojs
* Fixes #1925
2021-10-06 11:20:34 -07:00
Nico Jansen
1fc911e0fa Support running jasmine multiple times
Add support for running jasmine multiple times.

```js
const Jasmine = require('jasmine');

async function main() {
  const jasmine = new Jasmine({ projectBaseDir: process.cwd() });
  let specId = 'spec0';
  jasmine.loadConfigFile('./spec/support/jasmine.json');
  jasmine.env.configure({
    specFilter(sp) {
      return sp.id === specId;
    },
    autoCleanClosures: false
  });
  jasmine.exit = () => {};
  await jasmine.execute();
  specId = 'spec2';
  await jasmine.execute();
}

main().catch((err) => {
  console.error(err);
  process.exitCode = 1;
});
```

With `jasmine.env.configure({ autoCleanClosures: false })` you disable Jasmine's feature to automatically clean closures (functions) during the test run. This is a requirement to be able to rerun.

When `execute` is called more than once, the `topSuite.reset` is called, which will reset the state for the next run as well as reset any child suites.

Add a function `exclude` to the `Suite` and `Spec` clases. This functions similar to `pend`, but will allow the "pending" state to persist over multiple runs. This is useful when `xit` is used.

Revert changes to jasmine.js

fix: make sure to call hooks during second run

Remove jsdoc from private apis

Fix elint issue

Add new line
2021-10-06 20:12:45 +02:00
Steve Gravrock
15710937b8 Added a test that verifies skip to cleanup fns after pending()
Because pending() is implemented via the standard exception handling
path, we effectively got this feature for free as a result of the changes
for #1533, particularly 457a2727.

* [#178598493]
* Fixes #1579
2021-10-06 11:07:53 -07:00
Steve Gravrock
1a9d16715d Clarify which behaviors are specific to different stopSpecOnExpectationFailure values
* #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
b67a3043c7 Skip afterEach fns in nested suites when a beforeEach fn errors
This matches the behavior of beforeAll errors.

* #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
5f1ef5ac2b Skip everything except afterAll fns when a beforeAll fn errors
* Fixes #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
5eaeeb0b6c Moved fn skipping policy out of QueueRunner
This should allow us to more easily support complex skipping strategies
like skipping nested cleanup fns when the corresponding befores were
skipped, or skipping specs and suites when a beforeAll fails.

* #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
457a2727ba Skip to afterEach fns when a beforeEach fn errors
* #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
a1f14efac6 Improved specs for stopSpecOnExpectationFailure
* #1533
2021-10-06 08:55:01 -07:00
Steve Gravrock
b2067d9ce0 Fixed references to Env#trace in jsdocs 2021-10-02 09:58:47 -07:00
Steve Gravrock
47081258cd Revert "Revert "Added the ability to associate trace information with failing specs""
This reverts commit fdad8849df.
2021-10-02 09:56:25 -07:00
Steve Gravrock
9c03d4d3e9 Merge branch '3.99' into 4.0 2021-10-02 09:52:43 -07:00
Steve Gravrock
7f0087b805 Merge branch 'main' into 3.99 2021-10-02 09:47:30 -07:00
Steve Gravrock
fdad8849df Revert "Added the ability to associate trace information with failing specs"
Pushing this back to 4.0 in hopes of increasing the chance that third
party reporters will notice it and add support.

This reverts commit 7a289f1de7.
2021-10-02 09:45:15 -07:00
Steve Gravrock
7a289f1de7 Added the ability to associate trace information with failing specs
This is meant to aid in debugging failures, particularly intermittent
failures, in cases where interactive debugging or console.log aren't
suitable.
2021-09-25 16:19:28 -07:00
Steve Gravrock
ef981bb794 Run the browser-flakes build on the debugging branch 2021-09-25 15:50:34 -07:00
Steve Gravrock
c3fb3e985a Reject timeout values that are too large for setTimeout
See #1930
2021-09-25 15:43:31 -07:00
Steve Gravrock
7fc3408051 Expanded jsdocs for jasmine.DEFAULT_TIMEOUT_INTERVAL 2021-09-25 13:29:44 -07:00
Steve Gravrock
af1b43eeff Merge branch 'patch-1' of https://github.com/trusktr/jasmine into main
* Merges #1931 from @trusktr
* Adds discussion of max timeout value to jsdocs
2021-09-25 13:28:34 -07:00
Steve Gravrock
4c043717a9 Revert "Dogfood the new jasmine-npm completion interface"
This works, but until the -npm 3.10.0 is out, it creates a chicken and egg
problem where each of core 3.10.0 and -npm 3.10.0 needs to be released
after the other.

This reverts commit 1c9382c990.
2021-09-25 12:11:20 -07:00
Steve Gravrock
35064cf60e Merge branch '3.99' into 4.0 2021-09-24 14:31:02 -07:00
Steve Gravrock
fb4c16b23e Merge branch 'main' into 3.99 2021-09-24 14:27:15 -07:00
Steve Gravrock
3b28ee7c29 Fixed extra deprecation when passing custom equality testers to MatchersUtil#contains 2021-09-24 14:25:54 -07:00
Steve Gravrock
40be00310d Don't immediately move to the next queueable fn on async error
This allows assertion failures and other errors that occcur after the async
error to be routed to the correct spec/suite.

Previously, Jasmine treated global errors and unhandled promise rejections
just like exceptions thrown from a synchronous spec: it recorded the error
as a spec failure and moved on. Now, global errors and uhandled rejections
are recorded as failures but the current queueable fn will continue until
it either signals completion or times out. Global errors and unhandled
rejections are different from synchronous exceptions: it's common for the
queueable fn that caused them to continue executing. Immediately moving on
often meant that the queueable fn would produce expectation failures or
other errors when a different spec or suite was running, thus causing
those failures to be routed to the wrong place.
2021-09-24 11:22:04 -07:00
Steve Gravrock
3a77ae3dfe Throw if the argument to jasmine.clock().mockDate() is not a Date 2021-09-23 16:10:59 -07:00
Steve Gravrock
1332f01ca4 Merge branch '3.99' into 4.0 2021-09-23 16:08:44 -07:00
Steve Gravrock
64d58ed1f0 Deprecate non-Date arguments to jasmine.clock().mockDate() 2021-09-23 16:04:39 -07:00
Steve Gravrock
497a7fc3e5 Merge branch 'main' into 3.99 2021-09-23 15:49:47 -07:00
Steve Gravrock
1f318c3c93 Added missing @since annotations 2021-09-23 13:38:52 -07:00
Steve Gravrock
be29aa95eb Improved jsdocs for asymmetric equality testers 2021-09-23 11:59:20 -07:00
Steve Gravrock
e3c9a59c6c Added a stringContaining asymmetric equality tester
* Fixes #1923.
2021-09-22 11:28:24 -07:00
Joe Pea
b312ed4940 update base.js docs, mention setting DEFAULT_TIMEOUT_INTERVAL to a high number while debugging
This info is useful because if someone does not set the number to a high enough value while stepping through test code, before or after hooks may be triggered mid-test while the user is debugging which will be confusing.
2021-09-21 21:39:21 -07:00
Steve Gravrock
8d302d8dca Merge branch '3.99' into 4.0 2021-09-20 15:57:37 -07:00
Steve Gravrock
00f6708e1f Removed unused submodule 2021-09-18 09:43:02 -07:00
Steve Gravrock
760f2d9003 Removed additional Ruby support files 2021-09-18 09:40:30 -07:00
Steve Gravrock
6e10f22403 Don't display late errors as AfterAll errors in the HTML reporter 2021-09-11 08:57:50 -07:00
Steve Gravrock
d092a59bd1 Treat multiple calls to done callbacks as errors 2021-09-10 18:07:35 -07:00
Steve Gravrock
af5984d5d6 Fixed flake list 2021-09-10 17:53:59 -07:00
Steve Gravrock
15f7013f85 Merge branch '3.99' into 4.0 2021-09-08 21:04:10 -07:00
Steve Gravrock
be23836c9d Deprecate multiple calls to done callbacks 2021-09-08 20:58:25 -07:00
Steve Gravrock
7944250290 Merge branch 'main' into 3.99 2021-09-06 17:39:28 -07:00
Steve Gravrock
3a47a3bd04 Fixed flaky spec 2021-09-06 15:35:37 -07:00
Steve Gravrock
1c9382c990 Dogfood the new jasmine-npm completion interface 2021-09-04 13:39:17 -07:00
Steve Gravrock
394be99832 Fixed sass deprecation warnings
See <https://sass-lang.com/documentation/breaking-changes/slash-div>.
[#179260511]
2021-09-03 15:51:51 -07:00
Steve Gravrock
bbcb5ff42f Fixed linter & formatter issues in boot files 2021-09-03 15:46:23 -07:00
Steve Gravrock
6603ed7ddc Don't distribute boot src files
[#179017951]
2021-09-03 15:42:06 -07:00
Steve Gravrock
d61800c5c8 Removed support for custom promise libraries
All supported platforms now provide promises, so there's no longer a need
for Jasmine to be able to create them via a user-provided library. Jasmine
can still consume non-native promises but will always use the built-in
Promise object to create promises.

[#179078103]
2021-08-30 19:07:26 -07:00
Steve Gravrock
37b9f8e420 Removed Ruby support
[#179247162]
2021-08-30 18:53:13 -07:00
Steve Gravrock
a63b0b0368 Merge branch '3.99' into 4.0 2021-08-30 18:44:32 -07:00
Steve Gravrock
de9815f436 Merge branch 'main' into 3.99 2021-08-30 18:41:02 -07:00
Steve Gravrock
62a667a8e3 Added a deprecation notice to the gem's description
[#179330717]
2021-08-30 18:37:31 -07:00
Steve Gravrock
d277827d5e Fixed typo in 3.9.0 release notes 2021-08-21 19:09:01 -07:00
Steve Gravrock
644c175338 Print a deprecation message when the jasmine-core gem is loaded
[#179247158]
[#179247160]
2021-08-21 18:35:38 -07:00
Steve Gravrock
a6d7eb2a06 Bump version to 3.9.0 2021-08-21 12:00:23 -07:00
Steve Gravrock
2fd9d7b13f Merge branch 'main' into 3.99 2021-08-17 17:08:34 -07:00
Steve Gravrock
dd8a65cb60 Better reporting of unhandled promise rejections with truthy but non-Error reasons on Node
[#179227413]
2021-08-14 14:03:03 -07:00
Steve Gravrock
e72d161fab Return a promise from Env#execute in environments that support promises
[#178373231]
2021-08-07 13:05:55 -07:00
Steve Gravrock
4e96514634 Deprecated the Promise config setting
4.0 will only support environments that have native promises, so there will
no longer be a need for a user-supplied promise library
2021-08-07 12:04:14 -07:00
Steve Gravrock
d8862aa583 Removed the failFast and oneFailurePerSpec config properties 2021-07-31 09:28:14 -07:00
Steve Gravrock
2480a0a93a Merge branch '3.99' into 4.0 2021-07-31 09:15:12 -07:00
Steve Gravrock
9c9836c5b3 Don't use deprecated config prooperties in boot*.js 2021-07-31 09:09:46 -07:00
Steve Gravrock
20b914c554 Deprecated the failFast and oneFailurePerSpec config properties 2021-07-31 08:42:01 -07:00
Steve Gravrock
058e77b824 Merge branch 'main' into 3.99 2021-07-31 08:15:29 -07:00
Steve Gravrock
dcaac62a6c Updated deprecaton messages for Env#throwOnExpectationFailure() and Env#stopOnSpecFailure() 2021-07-31 08:02:39 -07:00
Steve Gravrock
b696bec9e3 Renamed failFast and oneFailurePerSpec config props to stopOnSpecFailure and stopSpecOnExpectationFailure
The new names are more self-explanatory and consistent with jasmine-npm. The
old names are deprecated but still work.

[#178682783]
2021-07-31 07:51:50 -07:00
Steve Gravrock
13dfcacbb0 Remove access to non-public properties of suites and specs returned by describe, it, etc.
[#179064612]
2021-07-30 17:36:50 -07:00
Steve Gravrock
6d002d22af Merge branch '3.99' into 4.0 2021-07-29 21:46:48 -07:00
Steve Gravrock
799d9897fd Deprecated access to non-public members in specs and suites returned from it(), describe(), etc. 2021-07-29 21:28:47 -07:00
Steve Gravrock
2a2a671b65 Don't deprecate access to Suite#id and Spec#id 2021-07-29 20:15:04 -07:00
Steve Gravrock
a0b4f3748d Merge branch 'main' into 3.99 2021-07-29 20:09:25 -07:00
Steve Gravrock
43073b3bc5 Added API docs for Suite#id and Spec#id
These properties are the only way to obtain runnable IDs, without which
you can't call the form of Env#execute that takes an array of IDs.
2021-07-29 19:32:15 -07:00
Steve Gravrock
09d2ce9bc9 Removed more code that supported browsers we no longer run on 2021-07-27 17:53:09 -07:00
Steve Gravrock
e9bddc7a06 Removed obsolete timing function hacks from boot1.js 2021-07-26 19:04:43 -07:00
Steve Gravrock
310e4d5e6c Removed legacy boot.js file 2021-07-26 18:29:54 -07:00
Steve Gravrock
0424d4ae99 Removed Python support 2021-07-26 18:28:38 -07:00
Steve Gravrock
0720c88252 Merge branch '3.99' into 4.0 2021-07-26 18:20:24 -07:00
Steve Gravrock
f26b005807 Deprecated the legacy boot.js file 2021-07-26 18:20:07 -07:00
Steve Gravrock
1206952ca6 Merge branch 'main' into 3.99 2021-07-26 18:19:11 -07:00
Steve Gravrock
286524959b Split boot.js in two to allow the env to be configured in between
This is mainly intended to support jasmine-browser-runner, which will load
a script that configures the env in between the two boot files (boot0.js and
boot1.js). The single-file boot.js is retained for now but will be removed
in a future release.
2021-07-26 18:05:36 -07:00
Steve Gravrock
c73df57720 MatchersUtil#contains uses deep equality rather than === for set members
[#169001712]
2021-07-24 14:23:05 -07:00
Steve Gravrock
0170005015 Treat any argument to the done callback as an error
This reduces the risk of incorrectly passing a spec due to not correctly
detecting that an argument is an `Error` instance. Detecting Error instances
in a way that's reliable and portable across different browsers, TrustedTypes,
and frames is difficult.

[Finishes #178267587]
2021-07-24 09:30:39 -07:00
Steve Gravrock
6f04044417 Merge branch '3.99' into 4.0 2021-07-24 09:25:19 -07:00
Steve Gravrock
70d49e5b57 Deprecate non-Error arguments passed to done()
[Finishes #178267600]
2021-07-24 09:18:24 -07:00
Steve Gravrock
ed9363f477 Removed bower.json
Bower itself has been deprecated for four years, so we should drop support
for it in 4.0.

[Finishes #178512921]
2021-07-24 08:23:09 -07:00
Steve Gravrock
fe0a83ba87 Removed support for Internet Explorer 2021-07-23 21:46:15 -07:00
Steve Gravrock
623eecdcec Removed json2.js
Environments that don't provide a JSON parser are ancient history.
2021-07-22 21:37:57 -07:00
Steve Gravrock
2c32dd5703 Run browser-flakes build before regular cron build 2021-07-20 17:57:54 -07:00
Steve Gravrock
a27280e9e7 Merge branch '3.99' into 4.0 2021-07-20 17:55:18 -07:00
Steve Gravrock
10601f5af6 Merge branch 'main' into 3.99 2021-07-20 17:47:17 -07:00
Steve Gravrock
c10ab4e704 Updated deprecation links 2021-07-20 16:50:31 -07:00
Steve Gravrock
c1d1d69be2 Fixed test failures in Chrome and Edge 2021-07-19 12:08:40 -07:00
Steve Gravrock
3513249d73 Built distribution 2021-07-19 12:08:18 -07:00
Steve Gravrock
21bfbbb721 Merge branch 'iserror-tt' of https://github.com/bjarkler/jasmine into main
* Fixes Trusted Types error in Chromium-based browsers
* Merges #1921 from @bjarkler
* Fixes #1910
2021-07-19 12:06:12 -07:00
Steve Gravrock
88b90ec258 Backfilled unit tests for j$.isError_ 2021-07-19 10:31:53 -07:00
Steve Gravrock
e399953174 Removed obsolete timing function hacks from boot.js 2021-07-17 17:49:53 -07:00
Steve Gravrock
4edac7d3d1 Dropped Safari <13 from test matrix 2021-07-10 09:21:41 -07:00
Steve Gravrock
9b3d4a2bf2 Merge branch '3.99' into 4.0 2021-07-10 09:13:28 -07:00
Steve Gravrock
17826cd044 Fixed deprecations in matchersUtilSpec 2021-07-10 09:11:10 -07:00
Steve Gravrock
6cb9507f62 Merge branch 'main' into 3.99 2021-07-10 08:58:14 -07:00
Steve Gravrock
50c88e7774 Mark Env#hideDisabled deprecated in jsdocs 2021-07-08 18:53:21 -07:00
Steve Gravrock
3e64ce3310 Removed property tests for MatchersUtil#equals
These might be useful for a function with a more restricted domain. But for
equals, which accepts two of literally anything, the short run was too short
to catch any problems and the long run tended to exceed the CircleCi timeout.
2021-07-03 08:37:15 -07:00
Steve Gravrock
00586e50e0 Bump version to 3.8.0 2021-07-01 17:06:14 -07:00
Bjarki
dc80a282ba Make j$.isError_ compatible with Trusted Types
The isError_ check uses a heuristic that calls the Function constructor
to determine if the given value is an Error object. This results in a
runtime violation in test suites that enforce Trusted Types.

Since Trusted Types are only supported in modern browsers (currently,
Chromium-based browsers), we can use a more straightforward heuristic in
environments where Trusted Types are supported.

Fixes #1910. See that thread for more details.
2021-07-01 20:21:44 +00:00
Steve Gravrock
27c650ec08 Updated package description 2021-06-30 17:10:51 -07:00
Steve Gravrock
56daa6f461 Merge branch 'select-spec' of https://github.com/jlpstolwijk/jasmine into main
* Merges #1920 from @jlpstolwijk
* Fixes spec filtering in Karma
* Fixes #1906
2021-06-29 17:10:06 -07:00
Joris Stolwijk
e4c7d8af45 new attempt for fixing #1906: add window.location.pathname to hrefs + comments + fixed tests 2021-06-29 14:03:25 +02:00
Steve Gravrock
ee88ecc614 Revert "add url pathName in toQueryString function - fixes (https://github.com/jasmine/jasmine/issues/1906 ) + comment + test"
Reverted because it breaks the option checkboxes in the HTML reporter, both
in the standalone distribution and in jasmine-browser-runner.

Reopens #1906.

This reverts commit 1e4f0d1545.
2021-06-28 12:42:05 -07:00
Steve Gravrock
ec038273f1 Updated contributing guide
* Removed outdated steps
* Replaced list of environments with a pointer to the README
* Misc copy edits
2021-06-26 11:33:03 -07:00
Steve Gravrock
c5bdd79a1e Added TS typings and jasmine-browser-runner to issue template 2021-06-26 11:21:19 -07:00
Steve Gravrock
dbc1a0aa56 Added expectAsync(...).already
* Causes async matchers to immediately fail if the promise is pending
* Fixes #1845
2021-06-23 20:13:01 -07:00
Steve Gravrock
5862b22aef Include rejection details in failure messages for toBeResolved and toBeResolvedWith
[#178559119]
2021-06-21 16:43:51 -07:00
Steve Gravrock
163f93d6ff Removed constructors from jsdocs of classes that aren't user-constructable 2021-06-21 14:19:31 -07:00
Steve Gravrock
1893bf6c16 Added jsdocs for asymmetric equality testers 2021-06-21 14:09:14 -07:00
Steve Gravrock
095745ab12 Removed gulp-jasmine-browser mention from README 2021-06-21 13:31:28 -07:00
Steve Gravrock
68db3f6fcf Merge branch 'select-spec' of https://github.com/jlpstolwijk/jasmine into main
* Merges #1907 from @jlpstolwijk
* Fixes #1906
* Fixes spec filtering in karma-jasmine-html-reporter
2021-06-14 17:59:29 -07:00
Joris Stolwijk
1e4f0d1545 add url pathName in toQueryString function - fixes (https://github.com/jasmine/jasmine/issues/1906 ) + comment + test 2021-06-14 15:05:12 +02:00
Steve Gravrock
c546d2cb6d Merge branch 'patch-1' of https://github.com/eltociear/jasmine into main
* Fixes typo in spec name
* Merges #1918 from @eltociear
2021-06-13 09:57:23 -07:00
Steve Gravrock
6e097528f5 Include only specified files in the NPM package 2021-06-13 09:52:01 -07:00
Ikko Ashimine
4e1f36cbb0 Fix typo in SpySpec.js
ommitted -> omitted
2021-06-12 10:00:36 +09:00
Steve Gravrock
0aee81cfb9 Remvoed checks for typed array support in the test suite
All supported browsers have all typed arrays except for Uint8ClampedArray,
BigInt64Array, and BigUint64Array.
2021-06-05 13:31:26 -07:00
Steve Gravrock
1e50b49092 Fixed test failures on IE 10 2021-06-05 13:13:46 -07:00
Steve Gravrock
6aecf16cde Test coverage for MatchersUtil#equals with typed arrays 2021-06-05 12:03:11 -07:00
Steve Gravrock
f2de1be96a Fixed "stop spec on expectation failure" checkbox in standalone
Fixes [#178248968].
2021-06-01 08:49:34 -07:00
Steve Gravrock
a0f6b77c3e Remove access to non-public Suite and Spec members via Env#topSuite 2021-05-29 18:57:56 -07:00
Steve Gravrock
3f3fb38cf1 Merge branch '3.99' into 4.0 2021-05-29 18:42:31 -07:00
Steve Gravrock
00c1e3d608 Deprecate access to non-public Suite and Spec members via Env#topSuite
The deprecation warning relies on Proxy, and won't work in environments
that don't have it. Among Jasmine's supported environments, that's Safari 9,
Safari 8, and all versions of IE.
2021-05-29 15:45:10 -07:00
Steve Gravrock
6a2a30d540 Improved & unified deprecation handling
* De-duplication now happens in core, not in reporters. This ensures that
  the console doesn't get flooded.
* Stack traces are opt-out, not opt-in.
* The current runnable is not reported or logged for certain deprecations
  where it's irrelevant.
* HtmlReporter shows stack traces in expandable widgets.
* Env#deprecated and Env#deprecatedOnceWithStack are merged.
2021-05-29 15:39:28 -07:00
Steve Gravrock
5f4a1c4276 Merge branch 'issue/1897' of https://github.com/Dari-K/jasmine into main
* Adds option for spyOnAllFunctions to include non-enumerable props
* Merges #1909 from @Dari-k
* Fixes #1897
2021-05-26 17:44:54 -07:00
Darius Keeley
a4ef3687ee Add optional param to spyOnAllFunctions to include non-enumerable properties 2021-05-25 11:37:24 +01:00
Steve Gravrock
e4e232864d Don't expose Suite objects as this of describe functions
This was a holdover from 1.x that should have been removed in 2.0,
but was missed. Suite is meant to be private, and almost none of
its methods can be safely called by user code.
2021-05-22 09:15:22 -07:00
Steve Gravrock
5acddcda4a Merge branch '3.99' into 4.0 2021-05-22 09:09:03 -07:00
Steve Gravrock
61fb353197 Deprecate access to Suite objects via this in describes
Jasmine 1.x exposed Suite objects to user code as the `this` in describe
functions. That should have been removed in 2.0 but it was missed. It
will be removed in 4.0. This change adds a deprecation warning if anything
on a describe's `this` is accessed.

The deprecation warning relies on Proxy, and won't work in environments
that don't have it. Among Jasmine's supported environments, that's Safari 9,
Safari 8, and all versions of IE. In those browsers, a describe's `this`
will still be a Suite for now, but there will be no deprecation warnings.
2021-05-22 09:07:31 -07:00
Steve Gravrock
9065b4c3b7 Added a jsdoc cross-reference from Configuration to its usage 2021-05-21 17:13:07 -07:00
Steve Gravrock
752441a66f Merge branch '3.99' into 4.0 2021-05-18 17:12:29 -07:00
Steve Gravrock
3e2872a1df Merge branch 'main' into 3.99 2021-05-18 17:07:34 -07:00
Steve Gravrock
140225e7c3 Isolate specs that are flaky in browsers
* Don't run them in browsers in the regular CI build
* Run them in browsers in a special nightly build
* Run them in Node in the regular CI build
* Run them when developers manually run the suite

This should allow the regular CI build to give us a more useful signal,
while keeping us from losing sight of the flaky specs.
2021-05-15 07:44:25 -07:00
Steve Gravrock
8b38389d56 Test against Node 16
* Replaced node-sass dependency that isn't compatible with Node 16
* Added Node 16 to CI matrix
* Fixes #1894
2021-05-13 17:18:57 -07:00
Steve Gravrock
b7c2a2f6fb Removed unused dev dependencies 2021-05-13 12:52:44 -07:00
Steve Gravrock
c5d4a40219 Deprecated Python 2021-05-08 12:06:49 -07:00
Steve Gravrock
c7c8b6b93e Added Chrome back to CI browser list 2021-05-04 17:24:06 -07:00
Steve Gravrock
8a42437059 Added a note about testing on Windows to the releasing instructions 2021-05-04 09:28:35 -07:00
Steve Gravrock
cacc6f4278 Skip the middle Safari versions to speed up CI 2021-04-24 15:07:23 -07:00
Steve Gravrock
d815e99456 Added jsdocs for Spy.callData.returnValue 2021-04-24 14:57:33 -07:00
Steve Gravrock
5e3f937221 Added a note about correct usage of async matchers 2021-04-24 12:43:25 -07:00
Steve Gravrock
1b97795684 Merge branch '3.99' into 4.0 2021-04-23 08:41:12 -07:00
Steve Gravrock
5504965bea Merge branch 'main' into 3.99 2021-04-23 08:40:25 -07:00
Steve Gravrock
d666f1efbb Run browser tests on push, except for PRs 2021-04-23 08:39:02 -07:00
Steve Gravrock
4515b76f07 Run browser tests on all non-PR branches 2021-04-23 08:37:29 -07:00
Steve Gravrock
0897e31a2d Run cron builds on 3.99 and 4.0 branches 2021-04-23 08:37:18 -07:00
Steve Gravrock
c2a714f168 Removed support for IE 10 and Safari 8 2021-04-23 08:14:19 -07:00
Steve Gravrock
c2b558a2da Fail specs that try to combine two forms of async 2021-04-22 22:44:37 -07:00
Steve Gravrock
235efe52f1 Fixed test failure in IE 2021-04-22 22:43:48 -07:00
Steve Gravrock
1e8619df88 Removed deprecated env methods 2021-04-22 22:38:08 -07:00
Steve Gravrock
4b2a14f1f3 Removed deprecated custom matcher, matchersUtil, pp, etc interfaces 2021-04-22 22:29:20 -07:00
Steve Gravrock
66189d742b Merge branch 'no-children' of https://github.com/johnjbarton/jasmine into 4.0
* Merges #1742 from @johnjbarton
2021-04-22 21:35:58 -07:00
Steve Gravrock
fb05da1fc3 Merge branch 'main' into 3.99 2021-04-22 17:23:08 -07:00
Steve Gravrock
9555cb9842 Pass Sauce tunnel identifier correctly 2021-04-17 16:14:45 -07:00
Steve Gravrock
d6fa9dd1a0 Fixed jsdocs for Spy#calls#thisFor 2021-04-17 12:32:59 -07:00
Steve Gravrock
25fbe0646a Merge branch 'spy-calls-thisFor' of https://github.com/ajvincent/jasmine into main
* Merges #1903 from @ajvincent
* Adds Spy#calls#thisFor
2021-04-17 12:14:41 -07:00
Steve Gravrock
316ce1e2d3 Updated contributing guide etc. 2021-04-17 11:54:11 -07:00
Steve Gravrock
82cc1083b6 Migrated from Travis to Circle CI 2021-04-17 11:34:56 -07:00
Steve Gravrock
c2f04ba627 Further compensate for clock jitter 2021-04-17 11:34:56 -07:00
Steve Gravrock
97a46f4560 Fixed test failures on Safari 8 and 9 2021-04-17 11:34:56 -07:00
Steve Gravrock
113134cdbd Fixed test failure in Firefox 68 ESR 2021-04-17 11:34:56 -07:00
Steve Gravrock
dad5f5fd6b Fixed test failure in Safari 8 2021-04-17 11:34:53 -07:00
Alexander J. Vincent
fa72544974 CallTracker.thisFor(): add test for undefined context object. 2021-04-13 18:35:04 -07:00
Alexander J. Vincent
e303de52ed Implement CallTracker.thisFor(). 2021-04-11 22:59:43 -07:00
Steve Gravrock
5f9315731e Improved handling of unhandled promise rejections with no error in Node
* Fixes #1759
2021-04-06 18:48:56 -07:00
Steve Gravrock
ce850c472a API docs for Env#topSuite and Suite 2021-04-03 11:09:30 -07:00
Steve Gravrock
8b3a6561b1 Merge branch 'main' into 3.99 2021-04-02 11:35:30 -07:00
Steve Gravrock
2fc5182ddc Added missing jsdocs
* Env#execute
* Env#allowRespy
* Enough of Spec to support spec filters
2021-03-31 18:16:58 -07:00
Steve Gravrock
6be2102b64 Built distribution 2021-03-26 17:27:14 -07:00
Steve Gravrock
c6a79d3ab7 Merge branch 'patch-2' of https://github.com/UziTech/jasmine into main
* Merges #1892 from @UziTech
* Fixes config.seed type in jsdocs
2021-03-26 17:25:30 -07:00
Tony Brix
3f232fba80 docs: seed can be number or string 2021-03-26 00:10:15 -05:00
Tony Brix
cde6ea79a3 docs: fix jsdoc seed type 2021-03-25 22:05:02 -05:00
Steve Gravrock
0782a73a98 Merge branch 'array_buffer' of https://github.com/Finesse/jasmine into main
* Adds support for ArrayBuffers to matchersUtil.equals
* Merges #1891 from @Finesse
* Merges #1689 from @dankurka
* Fixes #1687
2021-03-22 13:06:40 -07:00
Surgie Finesse
37073e2768 Fix the review notices 2021-03-22 19:26:33 +10:00
Surgie Finesse
f7f928fdd3 Merge remote-tracking branch 'upstream/main' into array_buffer
# Conflicts:
#	spec/core/matchers/matchersUtilSpec.js
2021-03-22 18:33:50 +10:00
Steve Gravrock
503b653a10 Travis browser matrix updates
* Added latest Safari
* Added the Firefox version that's closest to current ESR
2021-03-21 11:30:21 -07:00
Steve Gravrock
7a38db2e32 Fixed deprecations triggered from within asymmetricEqualityTesterArgCompatShim 2020-09-17 13:26:35 -07:00
Steve Gravrock
a1f1b4ae0f Merge branch 'main' into 3.99 2020-09-14 18:39:32 -07:00
Steve Gravrock
c39c110eca Deprecate describes with no children 2020-02-12 16:44:44 -08:00
Steve Gravrock
18b2646d1d Allow libraries to avoid "Passing custom equality testers to MatchersUtil#contains is deprecated" while remaining compatible with older jasmine versions
Previously, a custom matcher library that wanted to remain compatible with
Jasmine <= 3.5.x could not know whether or not Jasmine expected it to pass
custom equality testers to MatchersUtil#contains. Passing them would produce
a deprecation warning in newer versions and not passing them would break
compatibility with older versions. Now we use matcher factory arity to
determine whether to pass custom equality testers to the factory, which
allows libraries to do something like this:

function matcherFactory(util) {
   const customEqualityTesters = arguments[1];
   // customEqualityTesters will be undefined in newer versions of Jasmine
   // and defined in older versions that expect it to be passed back to
   // MatchersUtil#equals.
}
2020-02-12 15:24:43 -08:00
Steve Gravrock
9aed55bb91 Improved readability of matcher-related deprecations
* Include stack traces. This makes it easier to find the matcher that
needs to be updated, particularly when it comes from a library rather
than the user's own code.

* Show each deprecation only once unless `config.verboseDeprecations`
is set. Since matchers are often added in a global `beforeEach`, logging
deprecations every time can be overwhelming.
2020-02-12 15:24:43 -08:00
Steve Gravrock
90d6f9d73c Added deprecation messages to interfaces that will be removed in 4.0
* `jasmine.pp`
* `jasmine.matchersUtil`
* Matchers that expect to receive custom equality testers
* Passing custom equality testers to `matchersUtil.contains`
* Passing custom equality testers to `matchersUtil.equals`
2020-02-12 15:24:42 -08:00
johnjbarton
2369c8dba7 fix(env): Throw if nested describe has no children.
Users would like an error if it() is acciddently moved within a before/afterEach/All function.
The it() function calls ensureIsNotNested to report such an error. But if the user has no
other it() functions in the Suite, it() and thus ensureIsNotNested() is never called.

Here we check nested Suites for children; if none are found we throw.
2019-08-07 18:01:34 -07:00
Daniel Kurka
2745d7d515 Add support for ArrayBuffers to matcherUtil.equals.
Fixes #1687
2019-05-02 09:49:21 -07:00
177 changed files with 9486 additions and 5073 deletions

205
.circleci/config.yml Normal file
View File

@@ -0,0 +1,205 @@
# Run tests against supported Node versions, and (except for pull requests)
# against supported browsers.
version: 2.1
orbs:
node: circleci/node@3.0.0
executors:
node16:
docker:
- image: cimg/node:16.1.0-browsers
working_directory: ~/workspace
node14:
docker:
- image: circleci/node:14
working_directory: ~/workspace
node12_latest:
docker:
- image: circleci/node:12
working_directory: ~/workspace
node12_17:
docker:
- image: circleci/node:12.17
working_directory: ~/workspace
jobs:
build:
parameters:
executor:
type: executor
executor: << parameters.executor >>
steps:
- checkout
- run:
name: Report Node and NPM versions
command: echo "Using Node $(node --version) and NPM $(npm --version)"
- run:
name: Install dependencies
command: npm install
- run:
name: Build
command: npm run build
- persist_to_workspace:
root: .
paths:
- .
test_node: &test_node
parameters:
executor:
type: executor
executor: << parameters.executor >>
steps:
- attach_workspace:
at: .
- run:
name: Run tests
command: npm test
test_browsers: &test_browsers
executor: node14
environment:
SKIP_JASMINE_BROWSER_FLAKES: "true"
steps:
- attach_workspace:
at: .
- run:
name: Install Sauce Connect
command: |
cd /tmp
curl https://saucelabs.com/downloads/sc-4.6.4-linux.tar.gz | tar zxf -
chmod +x sc-4.6.4-linux/bin/sc
mkdir ~/workspace/bin
cp sc-4.6.4-linux/bin/sc ~/workspace/bin
~/workspace/bin/sc --version
- run:
name: Run tests
command: |
# Do everything in one step because Sauce Connect won't exit
# cleanly if we kill it from a different step than it started in.
export PATH=$PATH:$HOME/workspace/bin
export SAUCE_TUNNEL_IDENTIFIER=$CIRCLE_BUILD_NUM
scripts/start-sauce-connect sauce-pidfile
set +o errexit
scripts/run-all-browsers
exitcode=$?
set -o errexit
scripts/stop-sauce-connect $(cat sauce-pidfile)
exit $exitcode
test_browser_flakes:
<<: *test_browsers
environment:
SKIP_JASMINE_BROWSER_FLAKES: "false"
workflows:
version: 2
cron:
triggers:
- schedule:
# Times are UTC.
cron: "0 11 * * *"
filters:
branches:
only:
- main
- "3.99"
- "4.0"
jobs:
- build:
executor: node16
name: build_node_16
- build:
executor: node14
name: build_node_14
- build:
executor: node12_latest
name: build_node_12_latest
- build:
executor: node12_17
name: build_node_12_17
- test_node:
executor: node16
name: test_node_16
requires:
- build_node_16
- test_node:
executor: node12_latest
name: test_node_12_latest
requires:
- build_node_12_latest
- test_node:
executor: node12_17
name: test_node_12_17
requires:
- build_node_12_17
- test_browsers:
requires:
- build_node_14
filters:
branches:
ignore: /pull\/.*/ # Don't run on pull requests.
push:
jobs:
- build:
executor: node16
name: build_node_16
- build:
executor: node14
name: build_node_14
- build:
executor: node12_latest
name: build_node_12_latest
- build:
executor: node12_17
name: build_node_12_17
- test_node:
executor: node16
name: test_node_16
requires:
- build_node_16
- test_node:
executor: node14
name: test_node_14
requires:
- build_node_14
- test_node:
executor: node12_latest
name: test_node_12_latest
requires:
- build_node_12_latest
- test_node:
executor: node12_17
name: test_node_12_17
requires:
- build_node_12_17
- test_browsers:
requires:
- build_node_14
filters:
branches:
ignore: /pull\/.*/ # Don't run on pull requests.
browser-flakes:
triggers:
- schedule:
# Times are UTC.
cron: "0 10 * * *"
filters:
branches:
only:
- browser-flakes
jobs:
- build:
executor: node14
name: build_node_14
- test_browser_flakes:
requires:
- build_node_14
filters:
branches:
ignore: /pull\/.*/ # Don't run on pull requests.

View File

@@ -3,14 +3,6 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
[*.{js, json, sh, yml, gemspec}]
[*.{js, json, sh, yml}]
indent_style = space
indent_size = 2
[{Rakefile, .jshintrc}]
indent_style = space
indent_size = 2
[*.{py}]
indent_style = space
indent_size = 4

View File

@@ -1,29 +1,34 @@
# Developing for Jasmine Core
We welcome your contributions! Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists before starting work. What you're looking for may already have been done. If it hasn't, the community can help make your contribution better. If you want to contribute but don't know what to work on, [issues tagged ready for work](https://github.com/jasmine/jasmine/labels/ready%20for%20work) should have enough detail to get started.
We welcome your contributions! Thanks for helping make Jasmine a better project
for everyone. Please review the backlog and discussion lists before starting
work. What you're looking for may already have been done. If it hasn't, the
community can help make your contribution better. If you want to contribute but
don't know what to work on,
[issues tagged help needed](https://github.com/jasmine/jasmine/labels/help%20needed)
should have enough detail to get started.
## Links
- [Jasmine Google Group](http://groups.google.com/group/jasmine-js)
- [Jasmine-dev Google Group](http://groups.google.com/group/jasmine-js-dev)
- [Jasmine on PivotalTracker](https://www.pivotaltracker.com/n/projects/10606)
- [Jasmine backlog](https://www.pivotaltracker.com/n/projects/10606)
## General Workflow
## Before Submitting a Pull Request
Please submit pull requests via feature branches using the semi-standard workflow of:
1. Ensure all specs are green in browsers *and* node.
* Use `npm test` to test in Node.
* Use `npm run serve` to test in browsers.
2. Fix any eslint or prettier errors reported at the end of `npm test`. Prettier
errors can be automatically fixed by running `npm run cleanup`.
3. Build `jasmine.js` with `npm run build` and run all specs again. This
ensures that your changes self-test well.
5. Revert your changes to `jasmine.js` and `jasmine-html.js`. When we accept
your pull request, we will generate these files as a separate commit and
merge the entire branch into master.
```bash
git clone git@github.com:yourUserName/jasmine.git # Clone your fork
cd jasmine # Change directory
git remote add upstream https://github.com/jasmine/jasmine.git # Assign original repository to a remote named 'upstream'
git fetch upstream # Fetch changes not present in your local repository
git merge upstream/main # Sync local main with upstream repository
git checkout -b my-new-feature # Create your feature branch
git commit -am 'Add some feature' # Commit your changes
git push origin my-new-feature # Push to the branch
```
Once you've pushed a feature branch to your forked repo, you're ready to open a pull request. We favor pull requests with very small, single commits with a single purpose.
We only accept green pull requests. If you see that the CI build failed, please
fix it. Feel free to ask for help if you're stuck.
## Background
@@ -32,51 +37,43 @@ Once you've pushed a feature branch to your forked repo, you're ready to open a
* `/src` contains all of the source files
* `/src/core` - generic source files
* `/src/html` - browser-specific files
* `/src/boot` - sources for boot files (see below)
* `/spec` contains all of the tests
* mirrors the source directory
* there are some additional files
* `/dist` contains the standalone distributions as zip files
* `/lib` contains the generated files for distribution as the Jasmine Rubygem and the Python package
* `/lib` contains the compiled copy of Jasmine. This is used to self-test and
distributed as the `jasmine-core` Node, and Ruby packages.
### Self-testing
Note that Jasmine tests itself. The files in `lib` are loaded first, defining the reference `jasmine`. Then the files in `src` are loaded, defining the reference `jasmineUnderTest`. So there are two copies of the code loaded under test.
Jasmine tests itself. The files in `lib` are loaded first, defining the reference `jasmine`. Then the files in `src` are loaded, defining the reference `jasmineUnderTest`. So there are two copies of the code loaded under test.
The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa.
### `boot.js`
### `boot0.js` and `boot1.js`
This file does all of the setup necessary for Jasmine to work. It loads all of the code, creates an `Env`, attaches the global functions, and builds the reporter. It also sets up the execution of the `Env` - for browsers this is in `window.onload`. While the default in `lib` is appropriate for browsers, projects may wish to customize this file.
For example, for Jasmine development there is a different `dev_boot.js` for Jasmine development that does more work.
These files file does all of the setup necessary for Jasmine to work in a
browser. They load all of the code, create an `Env`, attach the global
functions, and build the reporter. It also sets up the execution of the
`Env` - for browsers this is in `window.onload`. While the default in `lib`
is appropriate for browsers, projects may wish to customize this file.
### Compatibility
Jasmine supports the following environments:
* Browsers
* IE10+
* Edge Latest
* Firefox Latest
* Chrome Latest
* Safari 8+
* Node.js
* 8
* 10
* 12
Jasmine runs in both Node and a variety of browsers. See the README for the
list of currently supported environments.
## Development
All source code belongs in `src/`. The `core/` directory contains the bulk of Jasmine's functionality. This code should remain browser- and environment-agnostic. If your feature or fix cannot be, as mentioned above, please degrade gracefully. Any code that depends on a browser (specifically, it expects `window` to be the global or `document` is present) should live in `src/html/`.
### Install Dependencies
### Install Dev Dependencies
Jasmine Core relies on Node.js.
To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http://gruntjs.com/), the [grunt-cli](https://github.com/gruntjs/grunt-cli) and ensure that `grunt` is on your path.
To install the Node dependencies, you will need Node.js and npm.
$ npm install --local
$ npm install
...will install all of the node modules locally. Now run
@@ -88,40 +85,37 @@ To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http:/
Or, How to make a successful pull request
* _Do not change the public interface_. Lots of projects depend on Jasmine and if you aren't careful you'll break them
* _Be environment agnostic_ - server-side developers are just as important as browser developers
* _Be browser agnostic_ - if you must rely on browser-specific functionality, please write it in a way that degrades gracefully
* _Write specs_ - Jasmine's a testing framework; don't add functionality without test-driving it
* _Write code in the style of the rest of the repo_ - Jasmine should look like a cohesive whole
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and ESLint - your contribution shouldn't break Jasmine for other users
* _Do not change the public interface_. Lots of projects depend on Jasmine and
if you aren't careful you'll break them.
* _Be environment agnostic_. Some people run their specs in browsers, others in
Node. Jasmine should support them all as much as possible.
* _Be browser agnostic_ - if you must rely on browser-specific functionality,
please write it in a way that degrades gracefully.
* _Write specs_ - Jasmine's a testing framework. Don't add functionality
without test-driving it.
* _Write code in the style of the rest of the repo_ - Jasmine should look like
a cohesive whole.
Key exceptions:
* Use `const` or `let` for new variable declarations, even if nearby code
uses `var`.
* New async specs should usually be async/await or promise-returning, not
callback based.
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and
ESLint/Prettier. Your contribution shouldn't break Jasmine for other users.
Follow these tips and your pull request, patch, or suggestion is much more likely to be integrated.
### Running Specs
Jasmine uses some internal tooling to test itself in browser on Travis. This tooling _should_ work locally as well.
Be sure to run the tests in at least one supported Node version and at least a
couple of supported browsers. To run the tests in Node, simply use `npm test`
as described above. To run the tests in a browser, run `npm run serve` and then
visit `http://localhost:8888`.
$ node spec/support/ci.js
If you have the necessary Selenium drivers installed (e.g. geckodriver or
chromedriver), you can also use Jasmine's CI tooling:
You can also set the `JASMINE_BROWSER` environment variable to specify which browser should be used.
The easiest way to run the tests in **Internet Explorer** is to run a VM that has IE installed. It's easy to do this with VirtualBox.
1. Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
1. Download a VM image [from Microsoft](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/). Select "VirtualBox" as the platform.
1. Unzip the downloaded archive. There should be an OVA file inside.
1. In VirtualBox, choose `File > Import Appliance` and select the OVA file. Accept the default settings in the dialog that appears. Now you have a Windows VM!
1. Run the VM and start IE.
1. With `npm run serve` running on your host machine, navigate to `http://10.0.2.2:8888` in IE.
## Before Committing or Submitting a Pull Request
1. Ensure all specs are green in browser *and* node
1. Ensure eslint and prettier are clean as part of your `npm test` command. You can run `npm run cleanup` to have prettier re-write the files.
1. Build `jasmine.js` with `npm run build` and run all specs again - this ensures that your changes self-test well
1. Revert your changes to `jasmine.js` and `jasmine-html.js`
* We do this because `jasmine.js` and `jasmine-html.js` are auto-generated (as you've seen in the previous steps) and accepting multiple pull requests when this auto-generated file changes causes lots of headaches
* When we accept your pull request, we will generate these files as a separate commit and merge the entire branch into main
Note that we use Travis for Continuous Integration. We only accept green pull requests.
$ JASMINE_BROWSER=<name of browser> npm run ci

View File

@@ -3,9 +3,12 @@
- When in doubt, create an issue here.
- If you have an issue with the Jasmine docs, file an issue in the docs repo
here: https://github.com/jasmine/jasmine.github.io
- If you have an issue with TypeScript typings, start a discussion at
[DefinitelyTpyed](https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package)
- This repository is for the core Jasmine framework
- If you are using a test runner that wraps Jasmine, consider filing an issue with that library if appropriate:
- [Jasmine npm](https://github.com/jasmine/jasmine-npm/issues)
- [Jasmine browser runner](https://github.com/jasmine/jasmine-browser/issues)
- [Jasmine gem](https://github.com/jasmine/jasmine-gem/issues)
- [Jasmine py](https://github.com/jasmine/jasmine-py/issues)
- [Gulp Jasmine Browser](https://github.com/jasmine/gulp-jasmine-browser/issues)

View File

@@ -24,7 +24,7 @@
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have read the [**CONTRIBUTING**](https://github.com/jasmine/jasmine/blob/main/.github/CONTRIBUTING.md) guide.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

3
.gitignore vendored
View File

@@ -17,11 +17,10 @@ pkg/*
.sass-cache/*
src/html/.sass-cache/*
node_modules/
*.pyc
sauce_connect.log
*.swp
build/
*.egg-info/
dist
nbproject/
*.iml
.envrc

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "pages"]
path = pages
url = https://github.com/pivotal/jasmine.git

View File

@@ -1,29 +0,0 @@
dist/
grunt/
node_modules
pkg/
release_notes/
spec/
src/
Gemfile
Gemfile.lock
Rakefile
jasmine-core.gemspec
.bundle/
.gitignore
.gitmodules
.idea
.jshintrc
.rspec
.sass-cache/
.travis.yml
*.sh
*.py
Gruntfile.js
lib/jasmine-core.rb
lib/jasmine-core/boot/
lib/jasmine-core/spec
lib/jasmine-core/version.rb
lib/jasmine-core/*.py
sauce_connect.log
ci.js

1
.rspec
View File

@@ -1 +0,0 @@
--color

View File

@@ -1,52 +0,0 @@
language: node_js
node_js: 14
script: $TEST_COMMAND
env:
global:
- USE_SAUCE=true
- TEST_COMMAND="bash travis-core-script.sh"
- secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo=
- secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g=
matrix:
include:
- node_js: "14"
env: JASMINE_LONG_PROPERTY_TESTS="y" TEST_COMMAND="npm test"
- node_js: "12"
env: TEST_COMMAND="npm test"
- node_js: "10"
env: TEST_COMMAND="npm test"
- env: JASMINE_BROWSER="internet explorer" SAUCE_BROWSER_VERSION=11 SAUCE_OS="Windows 8.1"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="internet explorer" SAUCE_BROWSER_VERSION=10 SAUCE_OS="Windows 8"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="firefox" SAUCE_BROWSER_VERSION='' SAUCE_OS="Windows 10"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="firefox" SAUCE_BROWSER_VERSION='68' SAUCE_OS="Windows 10"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="chrome" SAUCE_BROWSER_VERSION='' SAUCE_OS="Windows 10"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="safari" SAUCE_BROWSER_VERSION="13" SAUCE_OS="OS X 10.13"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="safari" SAUCE_BROWSER_VERSION="8" SAUCE_OS="OS X 10.10"
if: type != pull_request
addons:
sauce_connect: true
- env: JASMINE_BROWSER="MicrosoftEdge" SAUCE_BROWSER_VERSION="" SAUCE_OS="Windows 10"
if: type != pull_request
addons:
sauce_connect: true

View File

@@ -1,2 +0,0 @@
source 'https://rubygems.org'
gemspec

View File

@@ -16,12 +16,6 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['sass:dist', "cssUrlEmbed"]);
var version = require('./grunt/tasks/version.js');
grunt.registerTask('build:copyVersionToGem',
"Propagates the version from package.json to version.rb",
version.copyToGem);
grunt.registerTask('buildDistribution',
'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
[
@@ -34,17 +28,21 @@ module.exports = function(grunt) {
grunt.registerTask("execSpecsInNode",
"Run Jasmine core specs in Node.js",
function() {
var done = this.async(),
verifyNoGlobals(() => require('./lib/jasmine-core.js').noGlobals());
const done = this.async(),
Jasmine = require('jasmine'),
jasmineCore = require('./lib/jasmine-core.js'),
jasmine = new Jasmine({jasmineCore: jasmineCore});
jasmine.loadConfigFile('./spec/support/jasmine.json');
jasmine.onComplete(function(passed) {
done(passed);
});
jasmine.execute();
jasmine.exitOnCompletion = false;
jasmine.execute().then(
result => done(result.overallStatus === 'passed'),
err => {
console.error(err);
exit(1);
}
);
}
);
@@ -55,3 +53,14 @@ module.exports = function(grunt) {
}
);
};
function verifyNoGlobals(fn) {
const initialGlobals = Object.keys(global);
fn();
const extras = Object.keys(global).filter(k => !initialGlobals.includes(k));
if (extras.length !== 0) {
throw new Error('Globals were unexpectedly created: ' + extras.join(', '));
}
}

View File

@@ -1,6 +0,0 @@
recursive-include . *.py
prune node_modules
include lib/jasmine-core/*.js
include lib/jasmine-core/*.css
include images/*.png
include package.json

View File

@@ -1,6 +1,6 @@
<a name="README">[<img src="https://rawgithub.com/jasmine/jasmine/main/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
[![Build Status](https://travis-ci.com/jasmine/jasmine.svg?branch=main)](https://travis-ci.com/jasmine/jasmine)
[![Build Status](https://circleci.com/gh/jasmine/jasmine.svg?style=shield)](https://circleci.com/gh/jasmine/jasmine)
[![Open Source Helpers](https://www.codetriage.com/jasmine/jasmine/badges/users.svg)](https://www.codetriage.com/jasmine/jasmine)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine?ref=badge_shield)
@@ -11,7 +11,8 @@ Jasmine is a Behavior Driven Development testing framework for JavaScript. It do
Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
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).
Upgrading from Jasmine 2.x? Check out the [3.0 release notes](https://github.com/jasmine/jasmine/blob/v3.0.0/release_notes/3.0.md) for a list of what's new (including breaking changes).
Upgrading from Jasmine 3.x? Check out the 4.0 release notes for a list of
what's new (including breaking changes). You can also read the [upgrade guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0).
## Contributing
@@ -22,14 +23,8 @@ Please read the [contributors' guide](https://github.com/jasmine/jasmine/blob/ma
For the Jasmine NPM module:<br>
[https://github.com/jasmine/jasmine-npm](https://github.com/jasmine/jasmine-npm).
For the Jasmine Ruby Gem:<br>
[https://github.com/jasmine/jasmine-gem](https://github.com/jasmine/jasmine-gem).
For the Jasmine Python Egg:<br>
[https://github.com/jasmine/jasmine-py](https://github.com/jasmine/jasmine-py).
For the Jasmine headless browser gulp plugin:<br>
[https://github.com/jasmine/gulp-jasmine-browser](https://github.com/jasmine/gulp-jasmine-browser).
For the Jasmine browser runner:<br>
[https://github.com/jasmine/jasmine-browser](https://github.com/jasmine/jasmine-browser).
To install Jasmine standalone on your local box (where **_{#.#.#}_** below is substituted by the release number downloaded):
@@ -52,21 +47,24 @@ Add the following to your HTML file:
## Supported environments
Jasmine tests itself across many browsers (Safari, Chrome, Firefox, Microsoft Edge, and Internet Explorer) as well as nodejs.
Jasmine tests itself across popular browsers (Safari, Chrome, Firefox, and
Microsoft Edge) as well as nodejs.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14 |
| Safari | 8-13 |
| Node | 12.17+, 14, 16 |
| Safari | 14-15 |
| Chrome | Evergreen |
| Firefox | Evergreen, 68 |
| Firefox | Evergreen, 91 |
| Edge | Evergreen |
| Internet Explorer | 10, 11 |
For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us
at the time of release. Other browsers, as well as older & newer versions of some supported browsers, are likely to work.
However, Jasmine isn't tested against them and they aren't actively supported.
See the [release notes](https://github.com/jasmine/jasmine/tree/main/release_notes)
for the supported environments for each Jasmine release.
## Support
* Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js).

View File

@@ -13,13 +13,14 @@ Please attempt to keep commits to `main` small, but cohesive. If a feature is co
We attempt to stick to [Semantic Versioning](http://semver.org/). Most of the time, development should be against a new minor version - fixing bugs and adding new features that are backwards compatible.
The current version lives in the file `/package.json`. This version will be the version number that is currently released. When releasing a new version, update `package.json` with the new version and `grunt build:copyVersionToGem` to update the gem version number.
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
The current version lives in the file `/package.json`. This version will be
copied to `jasmine.js` when the distribution is built. When releasing a new
version, update `package.json` with the new version and `npm run build` to
update the gem version number.
Note that Jasmine should only use the "patch" version number in the following cases:
* Changes related to packaging for a specific platform (npm, gem, or pip).
* Changes related to packaging for a specific binding library (npm or browser-runner)
* Fixes for regressions.
When jasmine-core revs its major or minor version, the binding libraries should also rev to that version.
@@ -28,36 +29,25 @@ When jasmine-core revs its major or minor version, the binding libraries should
When ready to release - specs are all green and the stories are done:
1. Update the release notes in `release_notes` - use the Anchorman gem to generate the markdown file and edit accordingly
1. Update the release notes in `release_notes` - use the Anchorman gem to generate the markdown file and edit accordingly. Include a list of supported environments.
1. Update the version in `package.json`
1. Run `npm run build`.
1. Copy version to the Ruby gem with `grunt build:copyVersionToGem`
### Commit and push core changes
1. Commit release notes and version changes (jasmine.js, version.rb, package.json)
1. Run the browser tests using `scripts/run-all-browsers`.
1. Commit release notes and version changes (jasmine.js, package.json)
1. Push
1. Wait for Travis to go green
1. Wait for Circle CI to go green
### Build standalone distribution
1. Build the standalone distribution with `grunt buildStandaloneDist`
1. This will generate `dist/jasmine-standalone-<version>.zip`, which you will upload later (see "Finally" below).
### Release the core Ruby gem
1. __NOTE__: You will likely need to push a new jasmine gem with a dependent version right after this release. See below.
1. `rake release` - tags the repo with the version, builds the `jasmine-core` gem, pushes the gem to Rubygems.org. In order to release you will have to ensure you have rubygems creds locally.
### Release the core Python egg
Install [twine](https://github.com/pypa/twine)
1. `python setup.py sdist`
1. `twine upload dist/jasmine-core-<version>.tar.gz` You will need pypi credentials to upload the egg.
### Release the core NPM module
1. Run the tests on Windows. (CI only tests on Linux.)
1. `npm adduser` to save your credentials locally
1. `npm publish .` to publish what's in `package.json`
@@ -77,18 +67,10 @@ Probably only need to do this when releasing a minor version, and not a patch ve
1. Create release notes using Anchorman as above
1. In `package.json`, update both the package version and the jasmine-core dependency version
1. Commit and push.
1. Wait for Travis to go green again.
1. Wait for Circle CI to go green again.
1. Run the tests on Windows locally.
1. `grunt release `. (Note: This will publish the package by running `npm publish`.)
#### Gem
1. Create release notes using Anchorman as above
1. Update the version number in `lib/jasmine/version.rb`.
1. Update the jasmine-core dependency version in `jasmine.gemspec`.
1. Commit and push.
1. Wait for Travis to go green again.
1. `rake release`
### Finally
For each of the above GitHub repos:

View File

@@ -1,2 +0,0 @@
require "bundler"
Bundler::GemHelper.install_tasks

View File

@@ -1,40 +0,0 @@
{
"name": "jasmine-core",
"homepage": "https://jasmine.github.io",
"authors": [
"slackersoft <gregg@slackersoft.net>"
],
"description": "Official packaging of Jasmine's core files",
"keywords": [
"test",
"jasmine",
"tdd",
"bdd"
],
"license": "MIT",
"moduleType": "globals",
"main": "lib/jasmine-core/jasmine.js",
"ignore": [
"**/.*",
"dist",
"grunt",
"node_modules",
"pkg",
"release_notes",
"spec",
"src",
"Gemfile",
"Gemfile.lock",
"Rakefile",
"jasmine-core.gemspec",
"*.sh",
"*.py",
"Gruntfile.js",
"lib/jasmine-core.rb",
"lib/jasmine-core/boot/",
"lib/jasmine-core/spec",
"lib/jasmine-core/version.rb",
"lib/jasmine-core/*.py",
"sauce_connect.log"
]
}

View File

@@ -29,10 +29,10 @@ module.exports = {
cwd: libJasmineCore("")
},
{
src: [ "boot.js" ],
src: [ "boot0.js", "boot1.js" ],
dest: standaloneLibDir,
expand: true,
cwd: libJasmineCore("boot")
cwd: libJasmineCore("")
},
{
src: [ "SpecRunner.html" ],

View File

@@ -37,12 +37,16 @@ module.exports = {
],
dest: 'lib/jasmine-core/jasmine.js'
},
boot: {
src: ['lib/jasmine-core/boot/boot.js'],
dest: 'lib/jasmine-core/boot.js'
boot0: {
src: ['src/boot/boot0.js'],
dest: 'lib/jasmine-core/boot0.js'
},
boot1: {
src: ['src/boot/boot1.js'],
dest: 'lib/jasmine-core/boot1.js'
},
nodeBoot: {
src: ['lib/jasmine-core/boot/node_boot.js'],
src: ['src/boot/node_boot.js'],
dest: 'lib/jasmine-core/node_boot.js'
},
options: {

View File

@@ -1,9 +1,8 @@
const sass = require('node-sass');
const sass = require('sass');
module.exports = {
options: {
implementation: sass,
outputStyle: 'compact',
sourceComments: false
},
dist: {

View File

@@ -1,14 +0,0 @@
var grunt = require("grunt");
function gemLib(path) { return './lib/jasmine-core/' + path; }
function nodeToRuby(version) { return version.replace('-', '.'); }
module.exports = {
copyToGem: function() {
var versionRb = grunt.template.process(
grunt.file.read("grunt/templates/version.rb.jst"),
{ data: { jasmineVersion: nodeToRuby(global.jasmineVersion) }});
grunt.file.write(gemLib("version.rb"), versionRb);
}
};

View File

@@ -9,7 +9,9 @@
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script>
<!-- optional: include a file here that configures the Jasmine env -->
<script src="lib/jasmine-<%= jasmineVersion %>/boot1.js"></script>
<!-- include source files here... -->
<script src="src/Player.js"></script>

View File

@@ -1,9 +0,0 @@
#
# DO NOT Edit this file. Canonical version of Jasmine lives in the repo's package.json. This file is generated
# by a grunt task when the standalone release is built.
#
module Jasmine
module Core
VERSION = "<%= jasmineVersion %>"
end
end

View File

View File

@@ -1,19 +0,0 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "jasmine-core/version"
Gem::Specification.new do |s|
s.name = "jasmine-core"
s.version = Jasmine::Core::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Gregg Van Hove"]
s.summary = %q{JavaScript BDD framework}
s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
s.email = %q{jasmine-js@googlegroups.com}
s.homepage = "http://jasmine.github.io"
s.license = "MIT"
s.files = Dir.glob("./lib/**/*")
s.require_paths = ["lib"]
s.add_development_dependency "rake"
end

View File

@@ -1,15 +1,52 @@
module.exports = require("./jasmine-core/jasmine.js");
/**
* Note: Only available on Node.
* @module jasmine-core
*/
const jasmineRequire = require('./jasmine-core/jasmine.js');
module.exports = jasmineRequire;
/**
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
* @type {function}
* @return {jasmine}
*/
module.exports.boot = require('./jasmine-core/node_boot.js');
/**
* Boots a copy of Jasmine and returns an object containing the properties
* that would normally be added to the global object. If noGlobals is called
* multiple times, the same object is returned every time.
*
* Do not call boot() if you also call noGlobals().
*
* @example
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
*/
module.exports.noGlobals = (function() {
let jasmineInterface;
return function bootWithoutGlobals() {
if (!jasmineInterface) {
const jasmine = jasmineRequire.core(jasmineRequire);
const env = jasmine.getEnv({ suppressLoadErrors: true });
jasmineInterface = jasmineRequire.interface(jasmine, env);
}
return jasmineInterface;
};
}());
var path = require('path'),
fs = require('fs');
var rootPath = path.join(__dirname, "jasmine-core"),
bootFiles = ['boot.js'],
bootFiles = ['boot0.js', 'boot1.js'],
legacyBootFiles = ['boot.js'],
nodeBootFiles = ['node_boot.js'],
cssFiles = [],
jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, nodeBootFiles);
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles, nodeBootFiles);
fs.readdirSync(rootPath).forEach(function(file) {
if(fs.statSync(path.join(rootPath, file)).isFile()) {

View File

@@ -1,53 +0,0 @@
module Jasmine
module Core
class << self
def path
File.join(File.dirname(__FILE__), "jasmine-core")
end
def js_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - node_boot_files
end
SPEC_TYPES = ["core", "html", "node"]
def core_spec_files
spec_files("core")
end
def html_spec_files
spec_files("html")
end
def node_spec_files
spec_files("node")
end
def boot_files
["boot.js"]
end
def node_boot_files
["node_boot.js"]
end
def boot_dir
path
end
def spec_files(type)
raise ArgumentError.new("Unrecognized spec type") unless SPEC_TYPES.include?(type)
(Dir.glob(File.join(path, "spec", type, "*.js"))).map { |f| File.join("spec", type, File.basename(f)) }.uniq
end
def css_files
Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
end
def images_dir
File.join(File.dirname(__FILE__), '../images')
end
end
end
end

View File

@@ -1 +0,0 @@
from .core import Core

View File

@@ -1,161 +0,0 @@
/*
Copyright (c) 2008-2021 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
var jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
extend(global, jasmineInterface);
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};
var random = queryString.getParam("random");
if (random !== undefined && random !== "") {
config.random = random;
}
var seed = queryString.getParam("seed");
if (seed) {
config.seed = seed;
}
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer(),
filterSpecs: filterSpecs
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
env.configure(config);
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());

View File

@@ -1,139 +0,0 @@
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
var jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
extend(global, jasmineInterface);
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};
var random = queryString.getParam("random");
if (random !== undefined && random !== "") {
config.random = random;
}
var seed = queryString.getParam("seed");
if (seed) {
config.seed = seed;
}
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer(),
filterSpecs: filterSpecs
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
env.configure(config);
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());

64
lib/jasmine-core/boot0.js Normal file
View File

@@ -0,0 +1,64 @@
/*
Copyright (c) 2008-2022 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
This file starts the process of "booting" Jasmine. It initializes Jasmine,
makes its globals available, and creates the env. This file should be loaded
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
source files or spec files are loaded.
*/
(function() {
var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
var jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
for (var property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
})();

132
lib/jasmine-core/boot1.js Normal file
View File

@@ -0,0 +1,132 @@
/*
Copyright (c) 2008-2022 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
This file finishes 'booting' Jasmine, performing all of the necessary
initialization before executing the loaded environment and all of a project's
specs. This file should be loaded after `boot0.js` but before any project
source files or spec files are loaded. Thus this file can also be used to
customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can
be customized directly. If you only wish to configure the Jasmine env, you
can load another file that calls `jasmine.getEnv().configure({...})`
after `boot0.js` is loaded and before this file is loaded.
*/
(function() {
var env = jasmine.getEnv();
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() {
return window.location;
}
});
var filterSpecs = !!queryString.getParam('spec');
var config = {
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
stopSpecOnExpectationFailure: queryString.getParam(
'stopSpecOnExpectationFailure'
),
hideDisabled: queryString.getParam('hideDisabled')
};
var random = queryString.getParam('random');
if (random !== undefined && random !== '') {
config.random = random;
}
var seed = queryString.getParam('seed');
if (seed) {
config.seed = seed;
}
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
navigateWithNewParam: function(key, value) {
return queryString.navigateWithNewParam(key, value);
},
addToExistingQueryString: function(key, value) {
return queryString.fullStringWithNewParam(key, value);
},
getContainer: function() {
return document.body;
},
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
},
timer: new jasmine.Timer(),
filterSpecs: filterSpecs
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() {
return queryString.getParam('spec');
}
});
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
env.configure(config);
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
})();

View File

@@ -1,60 +0,0 @@
import pkg_resources
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
class Core(object):
@classmethod
def js_package(cls):
return __package__
@classmethod
def css_package(cls):
return __package__
@classmethod
def image_package(cls):
return __package__ + ".images"
@classmethod
def js_files(cls):
js_files = sorted(list(filter(lambda x: '.js' in x, pkg_resources.resource_listdir(cls.js_package(), '.'))))
# jasmine.js needs to be first
js_files.insert(0, 'jasmine.js')
# boot needs to be last
js_files.remove('boot.js')
js_files.append('boot.js')
return cls._uniq(js_files)
@classmethod
def css_files(cls):
return cls._uniq(sorted(filter(lambda x: '.css' in x, pkg_resources.resource_listdir(cls.css_package(), '.'))))
@classmethod
def favicon(cls):
return 'jasmine_favicon.png'
@classmethod
def _uniq(self, items, idfun=None):
# order preserving
if idfun is None:
def idfun(x): return x
seen = {}
result = []
for item in items:
marker = idfun(item)
# in old Python versions:
# if seen.has_key(marker)
# but in new ones:
if marker in seen:
continue
seen[marker] = 1
result.append(item)
return result

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2021 Pivotal Labs
Copyright (c) 2008-2022 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -72,6 +72,12 @@ jasmineRequire.HtmlReporter = function(j$) {
}
};
ResultsStateBuilder.prototype.jasmineDone = function(result) {
if (result.failedExpectations) {
this.failureCount += result.failedExpectations.length;
}
};
function HtmlReporter(options) {
var config = function() {
return (options.env && options.env.configuration()) || {};
@@ -187,6 +193,7 @@ jasmineRequire.HtmlReporter = function(j$) {
};
this.jasmineDone = function(doneResult) {
stateBuilder.jasmineDone(doneResult);
var banner = find('.jasmine-banner');
var alert = find('.jasmine-alert');
var order = doneResult && doneResult.order;
@@ -208,7 +215,10 @@ jasmineRequire.HtmlReporter = function(j$) {
' of ' +
totalSpecsDefined +
' specs - run all';
var skippedLink = addToExistingQueryString('spec', '');
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
var skippedLink =
(window.location.pathname || '') +
addToExistingQueryString('spec', '');
alert.appendChild(
createDom(
'span',
@@ -300,15 +310,18 @@ jasmineRequire.HtmlReporter = function(j$) {
} else {
return prefix;
}
} else {
} else if (failure.globalErrorType === 'afterAll') {
return afterAllMessagePrefix + failure.message;
} else {
return failure.message;
}
}
addDeprecationWarnings(doneResult);
for (i = 0; i < deprecationWarnings.length; i++) {
var context;
var children = [],
context;
switch (deprecationWarnings[i].runnableType) {
case 'spec':
@@ -321,13 +334,23 @@ jasmineRequire.HtmlReporter = function(j$) {
context = '';
}
deprecationWarnings[i].message.split('\n').forEach(function(line) {
children.push(line);
children.push(createDom('br'));
});
children[0] = 'DEPRECATION: ' + children[0];
children.push(context);
if (deprecationWarnings[i].stack) {
children.push(createExpander(deprecationWarnings[i].stack));
}
alert.appendChild(
createDom(
'span',
{ className: 'jasmine-bar jasmine-warning' },
'DEPRECATION: ' + deprecationWarnings[i].message,
createDom('br'),
context
children
)
);
}
@@ -420,9 +443,53 @@ jasmineRequire.HtmlReporter = function(j$) {
);
}
if (result.debugLogs) {
messages.appendChild(debugLogTable(result.debugLogs));
}
return failure;
}
function debugLogTable(debugLogs) {
var tbody = createDom('tbody');
debugLogs.forEach(function(entry) {
tbody.appendChild(
createDom(
'tr',
{},
createDom('td', {}, entry.timestamp.toString()),
createDom('td', {}, entry.message)
)
);
});
return createDom(
'div',
{ className: 'jasmine-debug-log' },
createDom(
'div',
{ className: 'jasmine-debug-log-header' },
'Debug logs'
),
createDom(
'table',
{},
createDom(
'thead',
{},
createDom(
'tr',
{},
createDom('th', {}, 'Time (ms)'),
createDom('th', {}, 'Message')
)
),
tbody
)
);
}
function summaryList(resultsTree, domParent) {
var specListNode;
for (var i = 0; i < resultsTree.children.length; i++) {
@@ -555,17 +622,20 @@ jasmineRequire.HtmlReporter = function(j$) {
);
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast;
failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast);
navigateWithNewParam('stopOnSpecFailure', !config.stopOnSpecFailure);
};
var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures'
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() {
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
navigateWithNewParam(
'stopSpecOnExpectationFailure',
!config.stopSpecOnExpectationFailure
);
};
var randomCheckbox = optionsMenuDom.querySelector(
@@ -635,24 +705,55 @@ jasmineRequire.HtmlReporter = function(j$) {
suite = suite.parent;
}
return addToExistingQueryString('spec', els.join(' '));
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
return (
(window.location.pathname || '') +
addToExistingQueryString('spec', els.join(' '))
);
}
function addDeprecationWarnings(result, runnableType) {
if (result && result.deprecationWarnings) {
for (var i = 0; i < result.deprecationWarnings.length; i++) {
var warning = result.deprecationWarnings[i].message;
if (!j$.util.arrayContains(warning)) {
deprecationWarnings.push({
message: warning,
runnableName: result.fullName,
runnableType: runnableType
});
}
deprecationWarnings.push({
message: warning,
stack: result.deprecationWarnings[i].stack,
runnableName: result.fullName,
runnableType: runnableType
});
}
}
}
function createExpander(stackTrace) {
var expandLink = createDom('a', { href: '#' }, 'Show stack trace');
var root = createDom(
'div',
{ className: 'jasmine-expander' },
expandLink,
createDom(
'div',
{ className: 'jasmine-expander-contents jasmine-stack-trace' },
stackTrace
)
);
expandLink.addEventListener('click', function(e) {
e.preventDefault();
if (root.classList.contains('jasmine-expanded')) {
root.classList.remove('jasmine-expanded');
expandLink.textContent = 'Show stack trace';
} else {
root.classList.add('jasmine-expanded');
expandLink.textContent = 'Hide stack trace';
}
});
return root;
}
function find(selector) {
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
}
@@ -666,11 +767,23 @@ jasmineRequire.HtmlReporter = function(j$) {
}
}
function createDom(type, attrs, childrenVarArgs) {
var el = createElement(type);
function createDom(type, attrs, childrenArrayOrVarArgs) {
var el = createElement(type),
children,
i;
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (j$.isArray_(childrenArrayOrVarArgs)) {
children = childrenArrayOrVarArgs;
} else {
children = [];
for (i = 2; i < arguments.length; i++) {
children.push(arguments[i]);
}
}
for (i = 0; i < children.length; i++) {
var child = children[i];
if (typeof child === 'string') {
el.appendChild(createTextNode(child));
@@ -699,11 +812,19 @@ jasmineRequire.HtmlReporter = function(j$) {
}
function specHref(result) {
return addToExistingQueryString('spec', result.fullName);
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
return (
(window.location.pathname || '') +
addToExistingQueryString('spec', result.fullName)
);
}
function seedHref(seed) {
return addToExistingQueryString('seed', seed);
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
return (
(window.location.pathname || '') +
addToExistingQueryString('seed', seed)
);
}
function defaultQueryString(key, value) {

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,489 +0,0 @@
/*
json2.js
2014-02-04
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== 'object') {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
var cx,
escapable,
gap,
indent,
meta,
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
};
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2021 Pivotal Labs
Copyright (c) 2008-2022 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module.exports = function(jasmineRequire) {
var jasmine = jasmineRequire.core(jasmineRequire);
var env = jasmine.getEnv({suppressLoadErrors: true});
var env = jasmine.getEnv({ suppressLoadErrors: true });
var jasmineInterface = jasmineRequire.interface(jasmine, env);

View File

@@ -1,9 +0,0 @@
#
# DO NOT Edit this file. Canonical version of Jasmine lives in the repo's package.json. This file is generated
# by a grunt task when the standalone release is built.
#
module Jasmine
module Core
VERSION = "3.7.1"
end
end

View File

@@ -1,13 +1,14 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "3.7.1",
"version": "4.0.1",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
},
"keywords": [
"test",
"testing",
"jasmine",
"tdd",
"bdd"
@@ -22,30 +23,32 @@
"ci": "node spec/support/ci.js",
"ci:performance": "node spec/support/ci.js jasmine-browser-performance.json"
},
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
"description": "Simple JavaScript testing framework for browsers and node.js",
"homepage": "https://jasmine.github.io",
"main": "./lib/jasmine-core.js",
"files": [
"MIT.LICENSE",
"README.md",
"images/*.{png,svg}",
"lib/**/*.{js,css}",
"package.json"
],
"devDependencies": {
"acorn": "^6.0.0",
"ejs": "^2.5.5",
"eslint": "^6.8.0",
"eslint-plugin-compat": "^3.8.0",
"express": "^4.16.4",
"fast-check": "^1.21.0",
"fast-glob": "^2.2.6",
"eslint": "^7.32.0",
"eslint-plugin-compat": "^4.0.0",
"glob": "^7.2.0",
"grunt": "^1.0.4",
"grunt-cli": "^1.3.2",
"grunt-contrib-compress": "^1.3.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-compress": "^2.0.0",
"grunt-contrib-concat": "^2.0.0",
"grunt-css-url-embed": "^1.11.1",
"grunt-sass": "^3.0.2",
"jasmine": "^3.4.0",
"jasmine-browser-runner": "^0.4.0",
"jsdom": "^15.0.0",
"load-grunt-tasks": "^4.0.0",
"node-sass": "^4.11.0",
"jasmine": "github:jasmine/jasmine-npm#main",
"jasmine-browser-runner": "github:jasmine/jasmine-browser#main",
"jsdom": "^19.0.0",
"load-grunt-tasks": "^5.1.0",
"prettier": "1.17.1",
"selenium-webdriver": "^3.6.0",
"sass": "^1.45.1",
"shelljs": "^0.8.3",
"temp": "^0.9.0"
},
@@ -56,8 +59,13 @@
"extends": [
"plugin:compat/recommended"
],
"env": {
"browser": true,
"node": true,
"es2017": true
},
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 2018
},
"rules": {
"quotes": [
@@ -73,6 +81,7 @@
"args": "none"
}
],
"no-implicit-globals": "error",
"block-spacing": "error",
"func-call-spacing": [
"error",
@@ -90,11 +99,10 @@
}
},
"browserslist": [
"Safari >= 8",
"Safari >= 13",
"last 2 Chrome versions",
"last 2 Firefox versions",
"Firefox 68",
"last 2 Edge versions",
"IE >= 10"
"Firefox >= 68",
"last 2 Edge versions"
]
}

57
release_notes/3.10.0.md Normal file
View File

@@ -0,0 +1,57 @@
# Jasmine Core 3.10 Release Notes
## New features and bug fixes
* Added support for running Jasmine multiple times
* If the env is configured with `autoCleanClosures: false`, then it can be
executed repeatedly.
* Merges #1934 from @nicojs
* Fixes #1925
* Improved error message when an async expectation occurs after the spec
finishes
* Merges #1937 from @AndreWillomitzer
* Fixes #1854
* Reject timeout values that are too large for setTimeout
* See #1930
* Don't immediately move to the next queueable fn on async error
This allows assertion failures and other errors that occur after the async
error to be routed to the correct spec/suite.
* Added a stringContaining asymmetric equality tester
* Fixes #1923.
* The jasmine-core Ruby gem now prints a deprecation message when loaded unless
the SUPPRESS_JASMINE_DEPRECATION environment variable is set.
## Documentation updates
* Added discussion of max timeout value to jsdocs
* Merges #1931 from @trusktr
* Added missing @since annotations
* Improved jsdocs for asymmetric equality testers
* Added a deprecation notice to the jasmine-core Ruby gem's description
## Supported environments
jasmine-core 3.10.0 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 8-14 |
| Chrome | 94 |
| Firefox | 93, 78, 68 |
| Edge | 94 |
| Internet Explorer | 10, 11 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

12
release_notes/3.10.1.md Normal file
View File

@@ -0,0 +1,12 @@
# Jasmine Core 3.10.1 Release Notes
## Bugfixes
* Fixed missing pendingReason in pending spec results
* Fixes [#1939](https://github.com/jasmine/jasmine/issues/1939)
* Merges [#1940](https://github.com/jasmine/jasmine/pull/1940) from @jan-molak
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

132
release_notes/3.8.0.md Normal file
View File

@@ -0,0 +1,132 @@
# Jasmine Core 3.8 Release Notes
## Summary
This is a maintenance release of Jasmine with a number of new features and fixes.
## Python deprecation
The Jasmine packages for Python are deprecated. We intend to continue releasing
them through the end of the 3.x series, but after that they will be
discontinued. We recommend migrating to the following alternatives:
* The [jasmine-browser-runner](https://github.com/jasmine/jasmine-browser)
npm package to run specs in browsers, including headless Chrome and
Saucelabs. This is the most direct replacement for the `jasmine server`
and `jasmine ci` commands provided by the `jasmine` Python package.
* The [jasmine](https://github.com/jasmine/jasmine-npm) npm package (
`npm install jasmine`) to run specs under Node.js.
* The standalone distribution from the
[latest Jasmine release](https://github.com/jasmine/jasmine/releases) to
run specs in browsers with no additional tools.
* The [jasmine-core](https://github.com/jasmine/jasmine) npm package if all
you need is the Jasmine assets. This is the direct equivalent of the
jasmine-core Python package.
## New features and bug fixes
* Fixed spec filtering in Karma
* Merges [#1920](https://github.com/jasmine/jasmine/pull/1920) from @jlpstolwijk
* Fixes [#1906](https://github.com/jasmine/jasmine/issues/1906)
* Added expectAsync(...).already
* Causes async matchers to immediately fail if the promise is pending
* See https://jasmine.github.io/api/3.8/async-matchers.html#already
* Fixes [#1845](https://github.com/jasmine/jasmine/issues/1845)
* Include rejection details in failure messages for toBeResolved and toBeResolvedWith
* Fixed "stop spec on expectation failure" checkbox in standalone
* Added option for spyOnAllFunctions to include non-enumerable props
* Makes spyOnAllFunctions work on instance methods of ES6 classes
* Merges [#1909](https://github.com/jasmine/jasmine/pull/1909) from @Dari-k
* Fixes [#1897](https://github.com/jasmine/jasmine/issues/1897)
* Added Spy#calls#thisFor
* Provides the `this` value for a given spy call
* Merges [#1903](https://github.com/jasmine/jasmine/pull/1903) from @ajvincent
* Improved handling of unhandled promise rejections with no error in Node
* Fixes [#1759](https://github.com/jasmine/jasmine/issues/1759)
## Documentation updates
* Updated package description
* Updated contributing guide
* Added TypeScript typings and jasmine-browser-runner to issue template
* Removed constructors from jsdocs of classes that aren't user-constructable
* Fixed config.seed type in jsdocs
* Merges [#1892](https://github.com/jasmine/jasmine/pull/1892) from @UziTech
* Added jsdocs for the following:
* asymmetric equality testers
* Env#execute
* Env#allowRespy
* The public portion of Spec
* Spy.callData.returnValue
* Env#topSuite and Suite
* Added a jsdoc cross-reference from Configuration to its usage
* Added a note about correct usage of async matchers
* Added support for ArrayBuffers to matchersUtil.equals
* Merges [#1891](https://github.com/jasmine/jasmine/pull/1892) from @Finesse
* Merges [#1689](https://github.com/jasmine/jasmine/pull/1892) from @dankurka
* Fixes [#1687](https://github.com/jasmine/jasmine/issues/1687)
## Internal notes
* Fixed typo in spec name
* Merges [#1918](https://github.com/jasmine/jasmine/pull/1918) from @eltociear
* Specify files to include in the NPM package rather than files to exclude
* Added test coverage for MatchersUtil#equals with typed arrays
* Removed checks for typed array support in the test suite
* All supported browsers have all typed arrays except for Uint8ClampedArray,
BigInt64Array, and BigUint64Array.
* Fixed test failures on IE 10
* Test matrix updates
* Added Node 16
* Added Safari 14
* Added Firefox 78 (closest match to current ESR)
* Removed Safari 10-12 to speed up CI. The newer and older versions we test
provide a good measure of safety.
* Replaced node-sass dev dependency that isn't compatible with Node 16
* Removed unused dev dependencies
* Migrated CI from Travis to Circle
* Compensate for clock jitter in specs
## Supported environments
jasmine-core 3.8.0 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 8-14 |
| Chrome | 91 |
| Firefox | 89, 68, 78 |
| Edge | 91 |
| Internet Explorer | 10, 11 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

65
release_notes/3.9.0.md Normal file
View File

@@ -0,0 +1,65 @@
# Jasmine Core 3.9 Release Notes
## New features and bug fixes
* Fixed Trusted Types error in `j$.isError_` in Chromium-based browsers
* Merges [#1921](https://github.com/jasmine/jasmine/pull/1921) from @bjarkler
* Fixes [#1910](https://github.com/jasmine/jasmine/issues/1910)
* Fixes [#1653](https://github.com/jasmine/jasmine/issues/1653)
* Better reporting of unhandled promise rejections with truthy but non-`Error`
reasons on Node
* `Env#execute` returns a promise in environments that support promises
* Renamed `failFast` and `oneFailurePerSpec` config props to `stopOnSpecFailure`
and `stopSpecOnExpectationFailure`
The new names are more self-explanatory and consistent with jasmine-npm. The
old names are deprecated but will still work until the next major release.
* Split `boot.js` into two files to allow the env to be configured in between
This is mainly intended to support jasmine-browser-runner, which will load
a script that configures the env in between the two boot files (`boot0.js` and
`boot1.js`). The single-file `boot.js` will still be included until the next
major release.
## Ruby deprecation
The Jasmine Ruby gems are deprecated. There will be no further releases after
the end of the Jasmine 3.x series. We recommend that most users migrate to the
[jasmine-browser-runner](https://github.com/jasmine/jasmine-browser)
npm package, which is the direct replacement for the `jasmine` gem.
If `jasmine-browser-runner` doesn't meet your needs, one of these might:
* The [jasmine](https://github.com/jasmine/jasmine-npm) npm package to run
specs in Node.js.
* The [standalone distribution](https://github.com/jasmine/jasmine#installation)
to run specs in browsers with no additional tools.
* The [jasmine-core](https://github.com/jasmine/jasmine) npm package if all
you need is the Jasmine assets. This is the direct equivalent of the
`jasmine-core` Ruby gem.
## Documentation updates
* Added API docs for `Suite#id` and `Spec#id`
* Marked `Env#hideDisabled` deprecated in jsdocs
------
## Supported environments
jasmine-core 3.9.0 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 8-14 |
| Chrome | 92 |
| Firefox | 91, 78, 68 |
| Edge | 92 |
| Internet Explorer | 10, 11 |
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

15
release_notes/3.99.0.md Normal file
View File

@@ -0,0 +1,15 @@
# Jasmine Core 3.99.0 Release Notes
## Summary
This release adds deprecation warnings for breaking changes that will be
introduced in Jasmine 4.0. Please see the
[migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
for more information.
This is the last planned release of jasmine-core for Ruby or Python. Versions
4.0 and later will be offered only via NPM and the standalone distribution.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

22
release_notes/3.99.1.md Normal file
View File

@@ -0,0 +1,22 @@
# Jasmine Core 3.99.1 Release Notes
This release fixes a bug in 3.99.0, which incorrectly reported a deprecation
warning when a promise returned from a function passed to `it`, `beforeEach`,
etc was resolved to a value.
## Supported environments
jasmine-core 3.99.1 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 10-14 |
| Chrome | 98 |
| Firefox | 97, 78, 68 |
| Edge | 98 |
| Internet Explorer | 10, 11 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

197
release_notes/4.0.0.md Normal file
View File

@@ -0,0 +1,197 @@
# Jasmine Core 4.0.0 Release Notes
## Summary
This is a major release. In addition to new features and bug fixes it contains
a number of breaking changes that are intended to diagnose common errors,
improve awkward or outdated APIs, and make Jasmine easier to maintain
and contribute to. If you're upgrading from Jasmine 3.x, we recommend installing
3.99 and fixing any deprecation warnings that it emits before updating to 4.0.
Please see the [migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
for more information. If you use the `jasmine` or `jasmine-browser-runner` NPM
packages, please read the release notes for those packages as well.
## Highlights
* Obsolete environments, most notably Internet Explorer, are no longer
supported. Jasmine now expects to run in an environment that provides most
of ES2017 and, in the case of Node, good interoperability between CommonJS
modules and ES modules.
* The Jasmine packages for Ruby and Python have been discontinued.
* Errors in `beforeAll` and `beforeEach` functions are handled better.
* Jasmine can optionally be used without creating globals in Node.
* Certain common async testing bugs are now reported as errors.
* A new debug logging feature makes it easier to debug failing specs,
particularly intermittent failures.
See details below.
## Breaking changes
### Changes to supported environments
The following previously supported environments are no longer supported:
* Internet Explorer
* PhantomJS
* Safari 8-13
* Firefox 68 and 78
* Node 10 and 12.0-12.16
* Python
* Ruby
* Bower
Although Jasmine 4.0 may still work in some of those environments, we no longer
test against them and won't try to maintain compatibility with them in future
4.x releases.
The [`jasmine-browser-runner`](https://jasmine.github.io/setup/browser.html)
NPM package is the direct replacement for the `jasmine` Ruby and Python
packages.
### Changes that affect how specs are written
* When a `beforeAll` function fails in any way other than a failed expectation,
Jasmine will not run the contents of the suite or any child suites except
for any `afterAll` functions defined in the same suite as the failed
`beforeAll` function. All affected specs will still be reported as failed.
See [#1533](https://github.com/jasmine/jasmine/issues/1533).
* When a `beforeEach` function fails in any way other than a failed expectation,
Jasmine will skip any subsequent `beforeEach` functions, the corresponding
spec, and any `afterEach` functions defined in child suites. `afterEach`
functions defined at the same or higher levels will still run. The spec will
still be reported as failed. See [#1533](https://github.com/jasmine/jasmine/issues/1533).
* `MatchersUtil#contains` and the `toContain` matcher use deep equality rather
than `===` to compare set members. This matches how arrays are handled but
may cause some previously passing `.not.toContain()` expectations to fail.
* `jasmine.clock().mockDate()` throws if its argument is not a `Date`. Previous
versions ignored non-`Date` arguments.
* Multiple calls to an asynchronous function's `done` callback are treated as
errors.
* Any argument passed to a `done` callback (other than `undefined`) is treated
as an error. Previous versions ignored any argument that wasn't an `Error`
instance.
* Jasmine will report an error rather than a warning when a function tries to
combine two different forms of async (e.g. taking a callback and also
returning a promise).
* `this` in `describe` functions is no longer a `Suite` object.
* Empty suites are treated as errors.
* Merges [#1742](https://github.com/jasmine/jasmine/pull/1742) from @johnjbarton
* The current time value does not decrease when `jasmine.clock().tick()` is
called from a `setTimeout` or `setInterval` callback.
* Merges [#1948](https://github.com/jasmine/jasmine/pull/1948) from @thw0rted
* Fixes [#1929](https://github.com/jasmine/jasmine/issues/1929).
### Changes to how Jasmine is configured
* Individual configuration property getters and setters such as
`Env#randomTests` and `Env#randomizeTests` have been removed. Use
`Env#configuration` and `Env#configure` instead.
* The `failFast` and `oneFailurePerSpec` configuration properties have been
removed. Use `stopOnSpecFailure` and `stopSpecOnExpectationFailure` instead.
* The `Promise` configuration property has been removed. Jasmine can still
consume non-native promises but will always use the global `Promise` to
create promises.
### Changes that affect custom matchers
* The old style of using custom equality testers, where matchers received them
from Jasmine and had to pass them back to `matchersUtil` methods, is no longer
supported.
* `matchersUtil` and `pp` are no longer available globally. Instead, use the
instances that are passed to custom matcher factories and to `jasmineToString`.
See the [migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
for more information about these changes and how to update custom matchers that
use the old APIs.
### Changes that affect custom reporters
* The [`Suite`](https://jasmine.github.io/api/4.0/Suite.html) and
[`Spec`](https://jasmine.github.io/api/4.0/Spec.html) objects returned from
`describe`, `it`, and `Env#topSuite` no longer expose private APIs.
### Other breaking changes
* `boot.js` is no longer included. Use `boot0.js` and `boot1.js` instead.
* Boot files in `lib/jasmine-core/boot` are no longer included in the NPM
package. Use the boot files in `lib/jasmine-core` instead.
* `json2.js` is no longer included, since all supported environments provide a
JSON parser.
## Other new features and bug fixes
* Jasmine can optionally be used without creating globals in Node.js.
* See https://jasmine.github.io/api/4.0/module-jasmine-core.html#.noGlobals
* If you're using the `jasmine` package, see
[its documentation](https://jasmine.github.io/api/npm/4.0/JasmineOptions.html#globals).
* Fixes [#1235](https://github.com/jasmine/jasmine/issues/1235)
* Custom spy strategies are inherited from parent suites like other runnable
resources.
* `pending()` can now be called from `beforeEach` functions.
* Fixes [#1579](https://github.com/jasmine/jasmine/issues/1579)
* Removed duplicate message from errors (including. matcher failures) in
V8-based environments.
* `Spy#withArgs` supports custom equality testers.
* Fixes [#1836](https://github.com/jasmine/jasmine/issues/1836)
* The promise returned by `Env#execute` is resolved to the
[jasmineDoneInfo](https://jasmine.github.io/api/4.0/global.html#JasmineDoneInfo).
* Fixed stack trace filtering on Safari 15.
* The HTML reporter includes top suite failures in the reported failure count.
* `afterAll` functions are run after a failure even if the `stopOnSpecFailure`
config property is set.
* Added a debug logging feature to make it easier to debug failing specs.
* Call `jasmine#debugLog` during spec execution to add a log entry.
* If the spec fails, log entries are reported as part of the
[specDone](https://jasmine.github.io/api/4.0/Reporter.html#specDone) reporter
event.
* The HTML reporter no longer says that expectations occurring after the spec
finishes are AfterAll errors.
## Documentation updates
* Added a [4.0 migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
* Updated the README and contributing guide for 4.0
## Supported environments
jasmine-core 4.0.0 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 12.17+, 14, 16 |
| Safari | 14-15 |
| Chrome | 96 |
| Firefox | 91, 95 |
| Edge | 96 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

21
release_notes/4.0.1.md Normal file
View File

@@ -0,0 +1,21 @@
# Jasmine Core 4.0.1 Release Notes
This release fixes a bug in 4.0.0, which incorrectly reported a failure
when a promise returned from a function passed to `it`, `beforeEach`,
etc was resolved to a value.
## Supported environments
jasmine-core 4.0.1 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 12.17+, 14, 16 |
| Safari | 14-15 |
| Chrome | 98 |
| Firefox | 91, 97 |
| Edge | 98 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -1 +0,0 @@
ordereddict==1.1

38
scripts/run-all-browsers Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/sh
run_browser() {
browser=$1
version=$2
description="$browser $version"
if [ $version = "latest" ]; then
version=""
fi
echo
echo
echo "Running $description"
echo
USE_SAUCE=true JASMINE_BROWSER=$browser SAUCE_BROWSER_VERSION=$version npm run ci
if [ $? -eq 0 ]; then
echo "PASS: $description" >> "$passfile"
else
echo "FAIL: $description" >> "$failfile"
fi
}
passfile=`mktemp -t jasmine-results.XXXXXX` || exit 1
failfile=`mktemp -t jasmine-results.XXXXXX` || exit 1
run_browser chrome latest
run_browser firefox latest
run_browser firefox 91
run_browser safari 15
run_browser safari 14
run_browser MicrosoftEdge latest
echo
cat "$passfile" "$failfile"
if [ -s "$failfile" ]; then
exit 1
fi

37
scripts/start-sauce-connect Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
if [ $# -gt 1 -o "$1" = "--help" ]; then
echo "Usage: $0 [pidfile]" 1>&2
exit
fi
if [ -z "$1" ]; then
pidfile=`mktemp`
else
pidfile="$1"
fi
outfile=`mktemp`
echo "Starting Sauce Connect"
if [ -z "$SAUCE_TUNNEL_IDENTIFIER" ]; then
sc -u "$SAUCE_USERNAME" -k "$SAUCE_ACCESS_KEY" -X 4445 --pidfile "$pidfile" 2>&1 | tee "$outfile" &
else
sc -u "$SAUCE_USERNAME" -k "$SAUCE_ACCESS_KEY" -X 4445 --pidfile "$pidfile" -i "$SAUCE_TUNNEL_IDENTIFIER" 2>&1 | tee "$outfile" &
fi
while ! fgrep "Sauce Connect is up, you may start your tests." "$outfile" > /dev/null; do
sleep 1
if ! ps -p $(cat "$pidfile") > /dev/null; then
echo "Sauce Connect exited"
exit 1
fi
done
if ! nc -z localhost 4445; then
echo "Can't connect to Sauce tunnel"
killall sc
exit 1
fi

33
scripts/stop-sauce-connect Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
if [ -z "$1" ]; then
echo "Usage: $0 sauce-connect-pid" 1>&2
exit
fi
pid="$1"
echo "PID: $pid"
echo "Stopping Sauce Connect"
# Sauce Connect docs say that we can just kill -9 it if we don't care about
# failing any ongoing sessions. In practice, that sometimes works but usually
# leaks a tunnel so badly that you can't even stop it from the web UI.
# Instead of doing that, we give Sauce Connect some time to shut down
# gracefully and then give up.
kill -INT $pid
# Wait up to 2 minutes, then give up if it's still running
n=0
while [ $n -lt 120 ] && ps -p $pid > /dev/null; do
sleep 1
kill -INT $pid 2> /dev/null || true
n=$(($n + 1))
done
if ps -p $pid > /dev/null; then
echo "Could not shut down Sauce Connect"
fi
exit $exitcode

View File

@@ -1,44 +0,0 @@
from setuptools import setup, find_packages, os
import json
with open('package.json') as packageFile:
version = json.load(packageFile)['version']
setup(
name="jasmine-core",
version=version,
url="http://jasmine.github.io",
author="Pivotal Labs",
author_email="jasmine-js@googlegroups.com",
description=('Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on '+
'browsers, DOM, or any JavaScript framework. Thus it\'s suited for websites, '+
'Node.js (http://nodejs.org) projects, or anywhere that JavaScript can run.'),
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Build Tools',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Testing',
],
packages=['jasmine_core', 'jasmine_core.images'],
package_dir={'jasmine_core': 'lib/jasmine-core', 'jasmine_core.images': 'images'},
package_data={'jasmine_core': ['*.js', '*.css'], 'jasmine_core.images': ['*.png']},
include_package_data=True,
install_requires=['glob2>=0.4.1', 'ordereddict==1.1']
)

View File

@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('AsyncExpectation', function() {
beforeEach(function() {
jasmineUnderTest.Expectation.addAsyncCoreMatchers(
@@ -6,23 +5,8 @@ describe('AsyncExpectation', function() {
);
});
describe('Factory', function() {
it('throws an Error if promises are not available', function() {
var thenable = { then: function() {} },
options = { global: {}, actual: thenable };
function f() {
jasmineUnderTest.Expectation.asyncFactory(options);
}
expect(f).toThrowError(
'expectAsync is unavailable because the environment does not support promises.'
);
});
});
describe('#not', function() {
it('converts a pass to a fail', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(),
@@ -44,8 +28,6 @@ describe('AsyncExpectation', function() {
});
it('converts a fail to a pass', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.reject(),
expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -69,7 +51,6 @@ describe('AsyncExpectation', function() {
});
it('propagates rejections from the comparison function', function() {
jasmine.getEnv().requirePromises();
var error = new Error('ExpectationSpec failure');
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
@@ -93,11 +74,9 @@ describe('AsyncExpectation', function() {
describe('#withContext', function() {
it('prepends the context to the generated failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
return 'failure message';
pp: function(val) {
return val.toString();
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
@@ -114,15 +93,14 @@ describe('AsyncExpectation', function() {
expect(addExpectationResult).toHaveBeenCalledWith(
false,
jasmine.objectContaining({
message: 'Some context: failure message'
message:
'Some context: Expected a promise to be resolved but it was rejected with rejected.'
})
);
});
});
it('prepends the context to a custom failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
return 'failure message';
@@ -144,7 +122,8 @@ describe('AsyncExpectation', function() {
false,
jasmine.objectContaining({
message:
"Some context: Expected a promise to be resolved to 'a' but it was rejected."
"Some context: Expected a promise to be resolved to 'a' " +
"but it was rejected with 'b'."
})
);
});
@@ -152,7 +131,6 @@ describe('AsyncExpectation', function() {
it('prepends the context to a custom failure message from a function', function() {
pending('should actually work, but no custom matchers for async yet');
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
@@ -181,8 +159,6 @@ describe('AsyncExpectation', function() {
});
it('works with #not', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(),
@@ -207,8 +183,6 @@ describe('AsyncExpectation', function() {
});
it('works with #not and a custom message', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve('a'),
expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -236,8 +210,6 @@ describe('AsyncExpectation', function() {
describe('async matchers', function() {
it('makes custom matchers available to this expectation', function() {
jasmine.getEnv().requirePromises();
var asyncMatchers = {
toFoo: function() {},
toBar: function() {}
@@ -253,8 +225,6 @@ describe('AsyncExpectation', function() {
});
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = function() {
return Promise.resolve({ pass: true });
},
@@ -267,29 +237,22 @@ describe('AsyncExpectation', function() {
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
customEqualityTesters = ['a'],
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
expectation = jasmineUnderTest.Expectation.asyncFactory({
matchersUtil: matchersUtil,
customAsyncMatchers: matchers,
customEqualityTesters: customEqualityTesters,
actual: 'an actual',
addExpectationResult: addExpectationResult
});
return expectation.toFoo('hello').then(function() {
expect(matcherFactory).toHaveBeenCalledWith(
matchersUtil,
customEqualityTesters
);
expect(matcherFactory).toHaveBeenCalledWith(matchersUtil);
});
});
it("wraps matchers's compare functions, passing the actual and expected", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = jasmine
.createSpy('fake-compare')
.and.returnValue(Promise.resolve({ pass: true })),
@@ -319,8 +282,6 @@ describe('AsyncExpectation', function() {
});
it('reports a passing result to the spec when the comparison passes', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -362,8 +323,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -407,8 +366,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result and a custom fail message to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -449,8 +406,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -493,8 +448,6 @@ describe('AsyncExpectation', function() {
});
it('reports a passing result to the spec when the comparison fails for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -533,8 +486,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -579,8 +530,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -622,8 +571,6 @@ describe('AsyncExpectation', function() {
});
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -665,8 +612,6 @@ describe('AsyncExpectation', function() {
});
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -711,8 +656,6 @@ describe('AsyncExpectation', function() {
});
it('reports errorWithStack when a custom error message is returned', function() {
jasmine.getEnv().requirePromises();
var customError = new Error('I am a custom error');
var matchers = {
toFoo: function() {
@@ -755,8 +698,6 @@ describe('AsyncExpectation', function() {
});
it("reports a custom message to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -797,8 +738,6 @@ describe('AsyncExpectation', function() {
});
it("reports a custom message func to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {

View File

@@ -30,6 +30,20 @@ describe('CallTracker', function() {
expect(callTracker.argsFor(1)).toEqual([0, 'foo']);
});
it("tracks the 'this' object from each execution", function() {
var callTracker = new jasmineUnderTest.CallTracker();
var this0 = {},
this1 = {};
callTracker.track({ object: this0, args: [] });
callTracker.track({ object: this1, args: [] });
callTracker.track({ args: [] });
expect(callTracker.thisFor(0)).toBe(this0);
expect(callTracker.thisFor(1)).toBe(this1);
expect(callTracker.thisFor(2)).toBe(undefined);
});
it('returns any empty array when there was no call', function() {
var callTracker = new jasmineUnderTest.CallTracker();

View File

@@ -950,6 +950,25 @@ describe('Clock (acceptance)', function() {
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
});
it('throws mockDate is called with a non-Date', function() {
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
global = { Date: Date },
mockDate = new jasmineUnderTest.MockDate(global),
clock = new jasmineUnderTest.Clock(
{ setTimeout: setTimeout },
function() {
return delayedFunctionScheduler;
},
mockDate
),
env = jasmineUnderTest.getEnv();
expect(() => clock.mockDate(12345)).toThrowError(
'The argument to jasmine.clock().mockDate(), if specified, should be ' +
'a Date instance.'
);
});
it('mocks the Date object and updates the date per delayed function', function() {
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
global = { Date: Date },

View File

@@ -0,0 +1,131 @@
describe('CompleteOnFirstErrorSkipPolicy', function() {
describe('#skipTo', function() {
describe('Before anything has errored', function() {
it('returns the next index', function() {
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
arrayOfArbitraryFns(4),
4
);
expect(policy.skipTo(1)).toEqual(2);
});
});
describe('After something has errored', function() {
it('skips non cleanup fns', function() {
const fns = arrayOfArbitraryFns(4);
fns[2].type = arbitraryCleanupType();
fns[3].type = arbitraryCleanupType();
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(2);
expect(policy.skipTo(2)).toEqual(3);
expect(policy.skipTo(3)).toEqual(4);
});
for (const type of ['afterEach', 'specCleanup', 'afterAll']) {
it(`does not skip ${type} fns`, function() {
const fns = arrayOfArbitraryFns(2);
fns[1].type = type;
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
fns
);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(1);
});
}
describe('When the error was in a beforeEach fn', function() {
it('runs cleanup fns defined by the current and containing suites', function() {
const parentSuite = { description: 'parentSuite' };
const suite = { description: 'suite', parentSuite };
const fns = [
{
suite: suite
},
{
fn: () => {}
},
{
fn: () => {},
suite: suite,
type: arbitraryCleanupType()
},
{
fn: () => {},
suite: parentSuite,
type: arbitraryCleanupType()
}
];
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
fns
);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(2);
expect(policy.skipTo(2)).toEqual(3);
});
it('skips cleanup fns defined by nested suites', function() {
const parentSuite = { description: 'parentSuite' };
const suite = { description: 'suite', parentSuite };
const fns = [
{
fn: () => {},
type: 'beforeEach',
suite: parentSuite
},
{
fn: () => {}
},
{
fn: () => {},
suite: suite,
type: arbitraryCleanupType()
},
{
fn: () => {},
suite: parentSuite,
type: arbitraryCleanupType()
}
];
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
fns
);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(3);
});
});
it('does not skip cleanup fns that have no suite, such as the spec complete fn', function() {
const fns = [
{ fn: () => {} },
{
fn: () => {},
type: arbitraryCleanupType()
}
];
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(1);
});
});
});
function arrayOfArbitraryFns(n) {
const result = [];
for (let i = 0; i < n; i++) {
result.push({ fn: () => {} });
}
return result;
}
function arbitraryCleanupType() {
return 'specCleanup';
}
});

View File

@@ -278,4 +278,58 @@ describe('DelayedFunctionScheduler', function() {
expect(tickDate).toHaveBeenCalledWith(0);
expect(tickDate).toHaveBeenCalledWith(1);
});
describe('ticking inside a scheduled function', function() {
let clock;
// Runner function calls the callback until it returns false
function runWork(workCallback) {
while (workCallback()) {}
}
// Make a worker that takes a little time and tracks when it finished
function mockWork(times) {
return () => {
clock.tick(1);
const now = new Date().getTime();
expect(lastWork)
.withContext('Previous function calls should always be in the past')
.toBeLessThan(now);
lastWork = now;
times--;
return times > 0;
};
}
let lastWork = 0;
beforeEach(() => {
clock = jasmineUnderTest.getEnv().clock;
clock.install();
clock.mockDate(new Date(1));
});
afterEach(function() {
jasmineUnderTest.getEnv().clock.uninstall();
});
it('preserves monotonically-increasing current time', () => {
const work1 = mockWork(3);
setTimeout(() => {
runWork(work1);
}, 1);
clock.tick(1);
expect(lastWork)
.withContext('tick should advance past last-scheduled function')
.toBeLessThanOrEqual(new Date().getTime());
const work2 = mockWork(3);
setTimeout(() => {
runWork(work2);
}, 1);
clock.tick(1);
expect(lastWork)
.withContext('tick should advance past last-scheduled function')
.toBeLessThanOrEqual(new Date().getTime());
});
});
});

329
spec/core/DeprecatorSpec.js Normal file
View File

@@ -0,0 +1,329 @@
/* eslint no-console: 0 */
describe('Deprecator', function() {
describe('#deprecate', function() {
beforeEach(function() {
spyOn(console, 'error');
});
it('logs the mesage without context when the runnable is the top suite', function() {
var runnable = { addDeprecationWarning: function() {} };
var deprecator = new jasmineUnderTest.Deprecator(runnable);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith('DEPRECATION: the message');
});
it('logs the message in a descendant suite', function() {
var runnable = {
addDeprecationWarning: function() {},
getFullName: function() {
return 'the suite';
},
children: []
};
var deprecator = new jasmineUnderTest.Deprecator({});
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: the message (in suite: the suite)'
);
});
it('logs and reports the message in a spec', function() {
var runnable = {
addDeprecationWarning: function() {},
getFullName: function() {
return 'the spec';
}
};
var deprecator = new jasmineUnderTest.Deprecator({});
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: the message (in spec: the spec)'
);
});
it('logs and reports the message without runnable info when ignoreRunnable is true', function() {
var topSuite = jasmine.createSpyObj('topSuite', [
'addDeprecationWarning',
'getFullName'
]);
var deprecator = new jasmineUnderTest.Deprecator(topSuite);
var runnable = jasmine.createSpyObj('spec', [
'addDeprecationWarning',
'getFullName'
]);
runnable.getFullName.and.returnValue('a spec');
deprecator.addDeprecationWarning(runnable, 'the message', {
ignoreRunnable: true
});
expect(topSuite.addDeprecationWarning).toHaveBeenCalledWith(
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
);
expect(runnable.addDeprecationWarning).not.toHaveBeenCalled();
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/the message/)
);
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/a spec/)
);
});
describe('with no options', function() {
it('includes the stack trace', function() {
testStackTrace(undefined);
});
});
it('omits the stack trace when omitStackTrace is true', function() {
testNoStackTrace({ omitStackTrace: true });
});
it('includes the stack trace when omitStackTrace is false', function() {
testStackTrace({ omitStackTrace: false });
});
it('includes the stack trace when omitStackTrace is undefined', function() {
testStackTrace({ includeStackTrace: undefined });
});
it('emits the deprecation only once when verboseDeprecations is not set', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(runnable2.addDeprecationWarning).not.toHaveBeenCalled();
});
it('emits the deprecation only once when verboseDeprecations is false', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(false);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(runnable2.addDeprecationWarning).not.toHaveBeenCalled();
});
it('emits the deprecation for each call when verboseDeprecations is true', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(2);
expect(runnable2.addDeprecationWarning).toHaveBeenCalled();
});
it('includes a note about verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message');
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
verboseDeprecationsNote()
);
});
it('omits the note about verboseDeprecations when verboseDeprecations is true', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message');
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).not.toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).not.toContain(
verboseDeprecationsNote()
);
});
describe('When the deprecation is an Error', function() {
// This form is used by external systems like atom-jasmine3-test-runner
// to report their own deprecations through Jasmine. See
// <https://github.com/jasmine/jasmine/pull/1498>.
it('passes the error through unchanged', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter();
var deprecation, originalStack;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
originalStack = err.stack;
}
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).toEqual('the deprecation');
expect(runnable.addDeprecationWarning.calls.argsFor(0)[0].stack).toBe(
originalStack
);
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0].message).toEqual(
'the deprecation'
);
expect(console.error.calls.argsFor(0)[0].stack).toEqual(originalStack);
});
it('reports the deprecation every time, regardless of config.verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var deprecation;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
}
deprecator.addDeprecationWarning(runnable, deprecation);
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(2);
expect(console.error).toHaveBeenCalledTimes(2);
});
it('omits the note about verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var deprecation;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
}
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).not.toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).not.toContain(
verboseDeprecationsNote()
);
});
});
function verboseDeprecationsNote() {
return (
'Note: This message will be shown only once. Set the ' +
'verboseDeprecations config property to true to see every occurrence.'
);
}
function testStackTrace(options) {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message', options);
expect(runnable.addDeprecationWarning).toHaveBeenCalledWith({
message: jasmine.stringMatching(/^the message/),
omitStackTrace: false
});
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).toContain('the message');
expect(console.error.calls.argsFor(0)[0]).toContain('DeprecatorSpec.js');
}
function testNoStackTrace(options) {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message', options);
expect(runnable.addDeprecationWarning).toHaveBeenCalledWith({
message: jasmine.stringMatching(/^the message/),
omitStackTrace: true
});
}
});
});

View File

@@ -26,9 +26,60 @@ describe('Env', function() {
});
describe('#topSuite', function() {
it('returns the Jasmine top suite for users to traverse the spec tree', function() {
var suite = env.topSuite();
it('returns an object that describes the tree of suites and specs', function() {
var suite;
spyOn(env, 'deprecated');
env.it('a top level spec');
env.describe('a suite', function() {
env.it('a spec');
env.describe('a nested suite', function() {
env.it('a nested spec');
});
});
suite = env.topSuite();
expect(suite).not.toBeInstanceOf(jasmineUnderTest.Suite);
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
expect(suite.getFullName()).toEqual('');
expect(suite.children.length).toEqual(2);
expect(suite.children[0]).not.toBeInstanceOf(jasmineUnderTest.Spec);
expect(suite.children[0].description).toEqual('a top level spec');
expect(suite.children[0].getFullName()).toEqual('a top level spec');
expect(suite.children[0].children).toBeFalsy();
expect(suite.children[1]).not.toBeInstanceOf(jasmineUnderTest.Suite);
expect(suite.children[1].description).toEqual('a suite');
expect(suite.children[1].getFullName()).toEqual('a suite');
expect(suite.children[1].parentSuite).toBe(suite);
expect(suite.children[1].children.length).toEqual(2);
expect(suite.children[1].children[0]).not.toBeInstanceOf(
jasmineUnderTest.Spec
);
expect(suite.children[1].children[0].description).toEqual('a spec');
expect(suite.children[1].children[0].getFullName()).toEqual(
'a suite a spec'
);
expect(suite.children[1].children[0].children).toBeFalsy();
expect(suite.children[1].children[1].description).toEqual(
'a nested suite'
);
expect(suite.children[1].children[1].getFullName()).toEqual(
'a suite a nested suite'
);
expect(suite.children[1].children[1].parentSuite).toBe(suite.children[1]);
expect(suite.children[1].children[1].children.length).toEqual(1);
expect(suite.children[1].children[1].children[0].description).toEqual(
'a nested spec'
);
expect(suite.children[1].children[1].children[0].getFullName()).toEqual(
'a suite a nested suite a nested spec'
);
expect(suite.children[1].children[1].children[0].children).toBeFalsy();
});
});
@@ -37,9 +88,9 @@ describe('Env', function() {
});
it('can configure specs to throw errors on expectation failures', function() {
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
spyOn(jasmineUnderTest, 'Spec');
spyOn(jasmineUnderTest, 'Spec').and.callThrough();
env.it('foo', function() {});
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(
jasmine.objectContaining({
@@ -49,7 +100,7 @@ describe('Env', function() {
});
it('can configure suites to throw errors on expectation failures', function() {
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
spyOn(jasmineUnderTest, 'Suite');
env.describe('foo', function() {});
@@ -60,33 +111,34 @@ describe('Env', function() {
);
});
describe('promise library', function() {
it('can be configured without a custom library', function() {
env.configure({});
env.configure({ Promise: undefined });
it('ignores configuration properties that are present but undefined', function() {
spyOn(env, 'deprecated');
var initialConfig = {
random: true,
seed: '123',
failSpecWithNoExpectations: true,
stopSpecOnExpectationFailure: true,
stopOnSpecFailure: true,
hideDisabled: true
};
env.configure(initialConfig);
env.configure({
random: undefined,
seed: undefined,
failSpecWithNoExpectations: undefined,
stopSpecOnExpectationFailure: undefined,
stopOnSpecFailure: undefined,
hideDisabled: undefined
});
it('can be configured with a custom library', function() {
var myLibrary = {
resolve: jasmine.createSpy(),
reject: jasmine.createSpy()
};
env.configure({ Promise: myLibrary });
});
it('cannot be configured with an invalid promise library', function() {
var myLibrary = {};
expect(function() {
env.configure({ Promise: myLibrary });
}).toThrowError(
'Custom promise library missing `resolve`/`reject` functions'
);
});
expect(env.configuration()).toEqual(
jasmine.objectContaining(initialConfig)
);
});
it('defaults to multiple failures for specs', function() {
spyOn(jasmineUnderTest, 'Spec');
spyOn(jasmineUnderTest, 'Spec').and.callThrough();
env.it('bar', function() {});
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(
jasmine.objectContaining({
@@ -105,7 +157,40 @@ describe('Env', function() {
);
});
function behavesLikeDescribe(methodName) {
it('returns a suite metadata object', function() {
let innerSuite;
let spec;
const suite = env.describe('outer suite', function() {
innerSuite = env.describe('inner suite', function() {
spec = env.it('a spec');
});
});
expect(suite.parentSuite).toEqual(
jasmine.objectContaining({
description: 'Jasmine__TopLevel__Suite'
})
);
expect(suite.parentSuite.pend).toBeUndefined();
expect(suite.pend).toBeUndefined();
expect(suite.description).toEqual('outer suite');
expect(suite.getFullName()).toEqual('outer suite');
expect(suite.id).toBeInstanceOf(String);
expect(suite.id).not.toEqual('');
expect(suite.children.length).toEqual(1);
expect(suite.children[0]).toBe(innerSuite);
expect(innerSuite.children.length).toEqual(1);
expect(innerSuite.children[0]).toBe(spec);
expect(innerSuite.getFullName()).toEqual('outer suite inner suite');
expect(innerSuite.parentSuite).toBe(suite);
expect(spec.getFullName()).toEqual('outer suite inner suite a spec');
});
}
describe('#describe', function() {
behavesLikeDescribe('describe');
it('throws an error when given arguments', function() {
expect(function() {
env.describe('done method', function(done) {});
@@ -141,14 +226,56 @@ describe('Env', function() {
);
expect(function() {
env.describe('fn arg', function() {});
env.describe('fn arg', function() {
env.it('has a spec', function() {});
});
}).not.toThrowError(
'describe expects a function argument; received [object Function]'
);
});
it('throws an error when it has no children', function() {
expect(function() {
env.describe('done method', function() {});
}).toThrowError('describe with no children (describe() or it())');
});
});
describe('#fdescribe', function() {
behavesLikeDescribe('fdescribe');
});
describe('xdescribe', function() {
behavesLikeDescribe('xdescribe');
});
function behavesLikeIt(methodName) {
it('returns a spec metadata object', function() {
let spec;
env.describe('a suite', function() {
spec = env[methodName]('a spec', function() {});
});
expect(spec.description)
.withContext('description')
.toEqual('a spec');
expect(spec.getFullName())
.withContext('getFullName')
.toEqual('a suite a spec');
expect(spec.id)
.withContext('id')
.toBeInstanceOf(String);
expect(spec.id)
.withContext('id')
.not.toEqual('');
expect(spec.pend).toBeFalsy();
});
}
describe('#it', function() {
behavesLikeIt('it');
it('throws an error when it receives a non-fn argument', function() {
expect(function() {
env.it('undefined arg', null);
@@ -164,17 +291,36 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
env.it('async', async function() {});
}).not.toThrow();
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.it('huge timeout', function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('#xit', function() {
behavesLikeIt('xit');
it('calls spec.exclude with "Temporarily disabled with xit"', function() {
var excludeSpy = jasmine.createSpy();
spyOn(env, 'it_').and.returnValue({
exclude: excludeSpy
});
env.xit('foo', function() {});
expect(excludeSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
});
it('calls spec.pend with "Temporarily disabled with xit"', function() {
var pendSpy = jasmine.createSpy();
spyOn(env, 'it').and.returnValue({
var realExclude = jasmineUnderTest.Spec.prototype.exclude;
spyOn(env, 'it_').and.returnValue({
exclude: realExclude,
pend: pendSpy
});
env.xit('foo', function() {});
@@ -196,14 +342,15 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction());
env.xit('async', async function() {});
}).not.toThrow();
});
});
describe('#fit', function() {
behavesLikeIt('fit');
it('throws an error when it receives a non-fn argument', function() {
expect(function() {
env.fit('undefined arg', undefined);
@@ -211,6 +358,12 @@ describe('Env', function() {
/fit expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/
);
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.fit('huge timeout', function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('#beforeEach', function() {
@@ -223,11 +376,16 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
env.beforeEach(async function() {});
}).not.toThrow();
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.beforeEach(function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('#beforeAll', function() {
@@ -240,11 +398,16 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
env.beforeAll(async function() {});
}).not.toThrow();
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.beforeAll(function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('#afterEach', function() {
@@ -257,11 +420,16 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
env.afterEach(async function() {});
}).not.toThrow();
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.afterEach(function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('#afterAll', function() {
@@ -274,11 +442,16 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
env.afterAll(async function() {});
}).not.toThrow();
});
it('throws an error when the timeout value is too large for setTimeout', function() {
expect(function() {
env.afterAll(function() {}, 2147483648);
}).toThrowError('Timeout value cannot be greater than 2147483647');
});
});
describe('when not constructed with suppressLoadErrors: true', function() {
@@ -378,4 +551,40 @@ describe('Env', function() {
done();
});
});
it("does not expose the suite as 'this'", function() {
var suiteThis;
spyOn(env, 'deprecated');
env.describe('a suite', function() {
suiteThis = this;
env.it('has a spec');
});
expect(suiteThis).not.toBeInstanceOf(jasmineUnderTest.Suite);
});
describe('#execute', function() {
it('returns a promise', function() {
expect(env.execute()).toBeInstanceOf(Promise);
});
it('should reset the topSuite when run twice', function() {
spyOn(jasmineUnderTest.Suite.prototype, 'reset');
return env
.execute() // 1
.then(function() {
return env.execute(); // 2
})
.then(function() {
var id;
expect(
jasmineUnderTest.Suite.prototype.reset
).toHaveBeenCalledOnceWith();
id = jasmineUnderTest.Suite.prototype.reset.calls.thisFor(0).id;
expect(id).toBeTruthy();
expect(id).toEqual(env.topSuite().id);
});
});
});
});

View File

@@ -225,5 +225,61 @@ describe('ExceptionFormatter', function() {
expect(result).toMatch(/error properties:.*someProperty.*hello there/);
});
describe('When omitMessage is true', function() {
it('filters the message from V8-style stack traces', function() {
const error = {
message: 'nope',
stack:
'Error: nope\n' +
' at fn1 (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
' at fn2 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n'
};
const subject = new jasmineUnderTest.ExceptionFormatter({
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
});
const result = subject.stack(error, { omitMessage: true });
expect(result).toEqual(
' at fn1 (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
' at <Jasmine>\n' +
' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)'
);
});
it('handles Webkit style traces that do not include a message', function() {
const error = {
stack:
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
'fn1@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
};
const subject = new jasmineUnderTest.ExceptionFormatter({
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
});
const result = subject.stack(error, { omitMessage: true });
expect(result).toEqual(
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
'<Jasmine>\n' +
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
);
});
it('ensures that stack traces do not include the message in this environment', function() {
let error;
try {
throw new Error('an error');
} catch (e) {
error = e;
}
const subject = new jasmineUnderTest.ExceptionFormatter({
jasmineFile: jasmine.util.jasmineFile()
});
const result = subject.stack(error, { omitMessage: true });
expect(result).not.toContain('an error');
});
});
});
});

View File

@@ -33,7 +33,11 @@ describe('Exceptions:', function() {
});
it('should handle exceptions thrown directly in top-level describe blocks and continue', function(done) {
var secondDescribe = jasmine.createSpy('second describe');
var secondDescribe = jasmine
.createSpy('second describe')
.and.callFake(function() {
env.it('has a test', function() {});
});
env.describe('a suite that throws an exception', function() {
env.it('is a test that should pass', function() {
this.expect(true).toEqual(true);

View File

@@ -50,7 +50,9 @@ describe('buildExpectationResult', function() {
stackFormatter: stackFormatter
});
expect(stackFormatter).toHaveBeenCalledWith(fakeError);
expect(stackFormatter).toHaveBeenCalledWith(fakeError, {
omitMessage: true
});
expect(result.stack).toEqual('foo');
});
@@ -66,7 +68,9 @@ describe('buildExpectationResult', function() {
stackFormatter: stackFormatter
});
expect(stackFormatter).toHaveBeenCalledWith(fakeError);
expect(stackFormatter).toHaveBeenCalledWith(fakeError, {
omitMessage: true
});
expect(result.stack).toEqual('foo');
});

View File

@@ -40,24 +40,19 @@ describe('Expectation', function() {
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
customEqualityTesters = ['a'],
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
expectation = jasmineUnderTest.Expectation.factory({
matchersUtil: matchersUtil,
customMatchers: matchers,
customEqualityTesters: customEqualityTesters,
actual: 'an actual',
addExpectationResult: addExpectationResult
});
expectation.toFoo('hello');
expect(matcherFactory).toHaveBeenCalledWith(
matchersUtil,
customEqualityTesters
);
expect(matcherFactory).toHaveBeenCalledWith(matchersUtil);
});
it("wraps matchers's compare functions, passing the actual and expected", function() {

View File

@@ -122,7 +122,7 @@ describe('GlobalErrors', function() {
errors.uninstall();
});
it('reports uncaughtException in node.js', function() {
it('reports uncaught exceptions in node.js', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
@@ -170,52 +170,118 @@ describe('GlobalErrors', function() {
);
});
it('reports unhandledRejection in node.js', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: jasmine.createSpy('process.removeListener'),
listeners: jasmine
.createSpy('process.listeners')
.and.returnValue(['foo']),
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
describe('Reporting unhandled promise rejections in node.js', function() {
it('reports rejections with `Error` reasons', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: jasmine.createSpy('process.removeListener'),
listeners: jasmine
.createSpy('process.listeners')
.and.returnValue(['foo']),
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
jasmine.any(Function)
);
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith(
'unhandledRejection'
);
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith(
'unhandledRejection'
);
errors.install();
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
jasmine.any(Function)
);
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith(
'unhandledRejection'
);
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith(
'unhandledRejection'
);
errors.pushListener(handler);
errors.pushListener(handler);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(new Error('bar'));
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(new Error('bar'));
expect(handler).toHaveBeenCalledWith(new Error('bar'));
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
'Unhandled promise rejection: Error: bar'
);
expect(handler).toHaveBeenCalledWith(new Error('bar'));
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
'Unhandled promise rejection: Error: bar'
);
errors.uninstall();
errors.uninstall();
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith(
'unhandledRejection',
addedListener
);
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
'foo'
);
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith(
'unhandledRejection',
addedListener
);
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
'foo'
);
});
it('reports rejections with non-`Error` reasons', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: function() {},
listeners: function() {
return [];
},
removeAllListeners: function() {}
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
errors.pushListener(handler);
expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual(
'unhandledRejection'
);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(17);
expect(handler).toHaveBeenCalledWith(
new Error(
'Unhandled promise rejection: 17\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject(...).)'
)
);
});
it('reports rejections with no reason provided', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: function() {},
listeners: function() {
return [];
},
removeAllListeners: function() {}
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
errors.pushListener(handler);
expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual(
'unhandledRejection'
);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(undefined);
expect(handler).toHaveBeenCalledWith(
new Error(
'Unhandled promise rejection with no error or message\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)'
)
);
});
});
describe('Reporting unhandled promise rejections in the browser', function() {

View File

@@ -99,7 +99,7 @@ describe('JsApiReporter', function() {
});
describe('#suiteResults', function() {
var reporter, suiteResult1, suiteResult2;
var reporter, suiteStarted1, suiteResult1, suiteResult2;
beforeEach(function() {
reporter = new jasmineUnderTest.JsApiReporter({});
suiteStarted1 = {

View File

@@ -96,24 +96,6 @@ describe('FakeDate', function() {
expect(fakeGlobal.Date.now()).toEqual(1000);
});
it("does not stub Date.now() if it doesn't already exist", function() {
var globalDate = jasmine.createSpy('global Date').and.callFake(function() {
return {
getTime: function() {
return 1000;
}
};
}),
fakeGlobal = { Date: globalDate },
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
mockDate.install();
expect(fakeGlobal.Date.now).toThrowError(
'Browser does not support Date.now()'
);
});
it('makes time passes using tick', function() {
var globalDate = jasmine.createSpy('global Date').and.callFake(function() {
return {

View File

@@ -18,8 +18,7 @@ describe('PrettyPrinter', function() {
describe('stringify sets', function() {
it('should stringify sets properly', function() {
jasmine.getEnv().requireFunctioningSets();
var set = new Set(); // eslint-disable-line compat/compat
var set = new Set();
set.add(1);
set.add(2);
var pp = jasmineUnderTest.makePrettyPrinter();
@@ -27,12 +26,11 @@ describe('PrettyPrinter', function() {
});
it('should truncate sets with more elements than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() {
jasmine.getEnv().requireFunctioningSets();
var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
try {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
var set = new Set(); // eslint-disable-line compat/compat
var set = new Set();
set.add('a');
set.add('b');
set.add('c');
@@ -46,20 +44,18 @@ describe('PrettyPrinter', function() {
describe('stringify maps', function() {
it('should stringify maps properly', function() {
jasmine.getEnv().requireFunctioningMaps();
var map = new Map(); // eslint-disable-line compat/compat
var map = new Map();
map.set(1, 2);
var pp = jasmineUnderTest.makePrettyPrinter();
expect(pp(map)).toEqual('Map( [ 1, 2 ] )');
});
it('should truncate maps with more elements than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() {
jasmine.getEnv().requireFunctioningMaps();
var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
try {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
var map = new Map(); // eslint-disable-line compat/compat
var map = new Map();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
@@ -272,15 +268,13 @@ describe('PrettyPrinter', function() {
});
it('should stringify immutable circular objects', function() {
if (Object.freeze) {
var pp = jasmineUnderTest.makePrettyPrinter();
var frozenObject = { foo: { bar: 'baz' } };
frozenObject.circular = frozenObject;
frozenObject = Object.freeze(frozenObject);
expect(pp(frozenObject)).toEqual(
"Object({ foo: Object({ bar: 'baz' }), circular: <circular reference: Object> })"
);
}
var pp = jasmineUnderTest.makePrettyPrinter();
var frozenObject = { foo: { bar: 'baz' } };
frozenObject.circular = frozenObject;
frozenObject = Object.freeze(frozenObject);
expect(pp(frozenObject)).toEqual(
"Object({ foo: Object({ bar: 'baz' }), circular: <circular reference: Object> })"
);
});
it('should stringify RegExp objects properly', function() {
@@ -299,20 +293,15 @@ describe('PrettyPrinter', function() {
it('should indicate getters on objects as such', function() {
var pp = jasmineUnderTest.makePrettyPrinter();
var sampleValue = { id: 1 };
if (sampleValue.__defineGetter__) {
//not supported in IE!
sampleValue.__defineGetter__('calculatedValue', function() {
var sampleValue = {
id: 1,
get calculatedValue() {
throw new Error("don't call me!");
});
}
if (sampleValue.__defineGetter__) {
expect(pp(sampleValue)).toEqual(
'Object({ id: 1, calculatedValue: <getter> })'
);
} else {
expect(pp(sampleValue)).toEqual('Object({ id: 1 })');
}
}
};
expect(pp(sampleValue)).toEqual(
'Object({ id: 1, calculatedValue: <getter> })'
);
});
it('should not do HTML escaping of strings', function() {

View File

@@ -18,26 +18,6 @@ describe('QueueRunner', function() {
expect(calls).toEqual(['fn1', 'fn2']);
});
it('runs cleanup functions after the others', function() {
var calls = [],
queueableFn1 = { fn: jasmine.createSpy('fn1') },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
cleanupFns: [queueableFn2]
});
queueableFn1.fn.and.callFake(function() {
calls.push('fn1');
});
queueableFn2.fn.and.callFake(function() {
calls.push('fn2');
});
queueRunner.execute();
expect(calls).toEqual(['fn1', 'fn2']);
});
it("calls each function with a consistent 'this'-- an empty object", function() {
var queueableFn1 = { fn: jasmine.createSpy('fn1') },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
@@ -149,31 +129,108 @@ describe('QueueRunner', function() {
expect(queueableFn2.fn).toHaveBeenCalled();
});
it('explicitly fails an async function when next is called with an Error and moves to the next function', function() {
var err = new Error('foo'),
queueableFn1 = {
fn: function(done) {
setTimeout(function() {
done(err);
}, 100);
}
},
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn
describe('When next is called with an argument', function() {
it('explicitly fails and moves to the next function', function() {
var err = 'anything except undefined',
queueableFn1 = {
fn: function(done) {
setTimeout(function() {
done(err);
}, 100);
}
},
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn
});
queueRunner.execute();
expect(failFn).not.toHaveBeenCalled();
expect(queueableFn2.fn).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(failFn).toHaveBeenCalledWith(err);
expect(queueableFn2.fn).toHaveBeenCalled();
});
describe('as a result of a promise', function() {
describe('and the argument is an Error', function() {
// Since promise support was added, Jasmine has failed specs that
// return a promise that resolves to an error. That's probably not
// the desired behavior but it's also not something we should change
// except on a major release and with a deprecation warning in
// advance.
it('explicitly fails and moves to the next function', function(done) {
var err = new Error('foo'),
queueableFn1 = {
fn: function() {
return Promise.resolve(err);
}
},
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn,
onComplete: function() {
expect(failFn).toHaveBeenCalledWith(err);
expect(queueableFn2.fn).toHaveBeenCalled();
done();
}
});
queueRunner.execute();
});
it('does not log a deprecation', function(done) {
var err = new Error('foo'),
queueableFn1 = {
fn: function() {
return Promise.resolve(err);
}
},
deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
deprecated: deprecated,
onComplete: function() {
expect(deprecated).not.toHaveBeenCalled();
done();
}
});
queueRunner.execute();
});
});
queueRunner.execute();
describe('and the argument is not an Error', function() {
it('does not log a deprecation or report a failure', function(done) {
var queueableFn1 = {
fn: function() {
return Promise.resolve('not an error');
}
},
failFn = jasmine.createSpy('fail'),
deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
deprecated: deprecated,
fail: failFn,
onComplete: function() {
expect(deprecated).not.toHaveBeenCalled();
expect(failFn).not.toHaveBeenCalled();
done();
}
});
expect(failFn).not.toHaveBeenCalled();
expect(queueableFn2.fn).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(failFn).toHaveBeenCalledWith(err);
expect(queueableFn2.fn).toHaveBeenCalled();
queueRunner.execute();
});
});
});
});
it('does not cause an explicit fail if execution is being stopped', function() {
@@ -225,6 +282,32 @@ describe('QueueRunner', function() {
expect(onComplete).toHaveBeenCalled();
});
it('does not call onMultipleDone if an asynchrnous function completes after timing out', function() {
var timeout = 3,
queueableFn = {
fn: function(done) {
queueableFnDone = done;
},
type: 'queueable',
timeout: timeout
},
onComplete = jasmine.createSpy('onComplete'),
onMultipleDone = jasmine.createSpy('onMultipleDone'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn],
onComplete: onComplete,
onMultipleDone: onMultipleDone
}),
queueableFnDone;
queueRunner.execute();
jasmine.clock().tick(timeout);
queueableFnDone();
expect(onComplete).toHaveBeenCalled();
expect(onMultipleDone).not.toHaveBeenCalled();
});
it('by default does not set a timeout for asynchronous functions', function() {
var beforeFn = { fn: function(done) {} },
queueableFn = { fn: jasmine.createSpy('fn') },
@@ -300,13 +383,16 @@ describe('QueueRunner', function() {
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
onMultipleDone = jasmine.createSpy('onMultipleDone'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn]
queueableFns: [queueableFn, nextQueueableFn],
onMultipleDone: onMultipleDone
});
queueRunner.execute();
jasmine.clock().tick(1);
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
expect(onMultipleDone).toHaveBeenCalled();
});
it('does not move to the next spec if done is called after an exception has ended the spec', function() {
@@ -317,13 +403,17 @@ describe('QueueRunner', function() {
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
deprecated: deprecated,
queueableFns: [queueableFn, nextQueueableFn]
});
queueRunner.execute();
jasmine.clock().tick(1);
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
// Don't issue a deprecation. The error already tells the user that
// something went wrong.
expect(deprecated).not.toHaveBeenCalled();
});
it('should return a null when you call done', function() {
@@ -456,20 +546,20 @@ describe('QueueRunner', function() {
}, 100);
return p1;
}
};
(queueableFn2 = {
fn: function() {
fnCallback();
setTimeout(function() {
p2.resolveHandler();
}, 100);
return p2;
}
}),
(queueRunner = new jasmineUnderTest.QueueRunner({
},
queueableFn2 = {
fn: function() {
fnCallback();
setTimeout(function() {
p2.resolveHandler();
}, 100);
return p2;
}
},
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
onComplete: onComplete
}));
});
queueRunner.execute();
expect(fnCallback).not.toHaveBeenCalled();
@@ -513,46 +603,43 @@ describe('QueueRunner', function() {
expect(queueableFn2.fn).toHaveBeenCalled();
});
it('issues a deprecation if the function also takes a parameter', function() {
it('issues an error if the function also takes a parameter', function() {
var queueableFn = {
fn: function(done) {
return new StubPromise();
}
},
deprecated = jasmine.createSpy('deprecated'),
onException = jasmine.createSpy('onException'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn],
deprecated: deprecated
}),
env = jasmineUnderTest.getEnv();
onException: onException
});
queueRunner.execute();
expect(deprecated).toHaveBeenCalledWith(
expect(onException).toHaveBeenCalledWith(
'An asynchronous ' +
'before/it/after function took a done callback but also returned a ' +
'promise. This is not supported and will stop working in the future. ' +
'promise. ' +
'Either remove the done callback (recommended) or change the function ' +
'to not return a promise.'
);
});
it('issues a more specific deprecation if the function is `async`', function() {
jasmine.getEnv().requireAsyncAwait();
it('issues a more specific error if the function is `async`', function() {
eval('var fn = async function(done){};');
var deprecated = jasmine.createSpy('deprecated'),
var onException = jasmine.createSpy('onException'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [{ fn: fn }],
deprecated: deprecated
onException: onException
});
queueRunner.execute();
expect(deprecated).toHaveBeenCalledWith(
expect(onException).toHaveBeenCalledWith(
'An asynchronous ' +
'before/it/after function was defined with the async keyword but ' +
'also took a done callback. This is not supported and will stop ' +
'working in the future. Either remove the done callback ' +
'also took a done callback. Either remove the done callback ' +
'(recommended) or remove the async keyword.'
);
});
@@ -617,6 +704,67 @@ describe('QueueRunner', function() {
expect(nextQueueableFn.fn).toHaveBeenCalled();
});
describe('When configured with a skip policy', function() {
it('instantiates the skip policy', function() {
const SkipPolicy = jasmine.createSpy('SkipPolicy ctor');
const queueableFns = [{ fn: () => {} }, { fn: () => {} }];
new jasmineUnderTest.QueueRunner({
queueableFns,
SkipPolicy
});
expect(SkipPolicy).toHaveBeenCalledWith(queueableFns);
});
it('uses the skip policy to determine which fn to run next', function() {
const queueableFns = [
{ fn: jasmine.createSpy('fn0') },
{ fn: jasmine.createSpy('fn1') },
{ fn: jasmine.createSpy('fn2').and.throwError(new Error('nope')) },
{ fn: jasmine.createSpy('fn3') }
];
const skipPolicy = jasmine.createSpyObj('skipPolicy', [
'skipTo',
'fnErrored'
]);
skipPolicy.skipTo.and.callFake(function(lastRanIx) {
return lastRanIx === 0 ? 2 : lastRanIx + 1;
});
const queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns,
SkipPolicy: function() {
return skipPolicy;
}
});
queueRunner.execute();
expect(skipPolicy.skipTo).toHaveBeenCalledWith(0);
expect(skipPolicy.skipTo).toHaveBeenCalledWith(2);
expect(skipPolicy.fnErrored).toHaveBeenCalledWith(2);
expect(queueableFns[0].fn).toHaveBeenCalled();
expect(queueableFns[1].fn).not.toHaveBeenCalled();
expect(queueableFns[2].fn).toHaveBeenCalled();
expect(queueableFns[3].fn).toHaveBeenCalled();
});
it('throws if the skip policy returns the current fn', function() {
const skipPolicy = { skipTo: i => i };
const queueableFns = [{ fn: () => {} }];
const queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns,
SkipPolicy: function() {
return skipPolicy;
}
});
expect(function() {
queueRunner.execute();
}).toThrowError("Can't skip to the same queueable fn that just finished");
});
});
describe('When configured to complete on first error', function() {
it('skips to cleanup functions on the first exception', function() {
var queueableFn = {
@@ -625,13 +773,15 @@ describe('QueueRunner', function() {
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
cleanupFn = {
fn: jasmine.createSpy('cleanup'),
type: 'specCleanup'
},
onComplete = jasmine.createSpy('onComplete'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
onComplete: onComplete,
completeOnFirstError: true
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
});
queueRunner.execute();
@@ -647,13 +797,16 @@ describe('QueueRunner', function() {
cleanupFn1 = {
fn: function() {
throw new Error('error');
}
},
type: 'afterEach'
},
cleanupFn2 = {
fn: jasmine.createSpy('cleanupFn2'),
type: 'afterEach'
},
cleanupFn2 = { fn: jasmine.createSpy('cleanupFn2') },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn],
cleanupFns: [cleanupFn1, cleanupFn2],
completeOnFirstError: true
queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
});
queueRunner.execute();
@@ -669,11 +822,15 @@ describe('QueueRunner', function() {
jasmine.clock().uninstall();
});
it('skips to cleanup functions on the first exception', function() {
it('skips to cleanup functions once the fn completes after an unhandled exception', function() {
var errorListeners = [],
queueableFn = { fn: function(done) {} },
queueableFn = {
fn: function(done) {
queueableFnDone = done;
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' },
queueRunner = new jasmineUnderTest.QueueRunner({
globalErrors: {
pushListener: function(f) {
@@ -683,13 +840,15 @@ describe('QueueRunner', function() {
errorListeners.pop();
}
},
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true
});
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
}),
queueableFnDone;
queueRunner.execute();
errorListeners[errorListeners.length - 1](new Error('error'));
expect(cleanupFn.fn).not.toHaveBeenCalled();
queueableFnDone();
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
expect(cleanupFn.fn).toHaveBeenCalled();
});
@@ -701,11 +860,10 @@ describe('QueueRunner', function() {
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
});
queueRunner.execute();
@@ -721,11 +879,13 @@ describe('QueueRunner', function() {
}
},
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
cleanupFn = {
fn: jasmine.createSpy('cleanup'),
type: 'specCleanup'
},
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
});
queueRunner.execute();

View File

@@ -0,0 +1,84 @@
describe('SkipAfterBeforeAllErrorPolicy', function() {
describe('#skipTo', function() {
describe('When nothing has errored', function() {
it('does not skip anything', function() {
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(
arrayOfArbitraryFns(4)
);
expect(policy.skipTo(0)).toEqual(1);
expect(policy.skipTo(1)).toEqual(2);
expect(policy.skipTo(2)).toEqual(3);
expect(policy.skipTo(3)).toEqual(4);
});
});
describe('When anything but a beforeAll has errored', function() {
it('does not skip anything', function() {
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(
arrayOfArbitraryFns(4)
);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(1);
policy.fnErrored(1);
expect(policy.skipTo(1)).toEqual(2);
policy.fnErrored(2);
expect(policy.skipTo(2)).toEqual(3);
policy.fnErrored(3);
expect(policy.skipTo(3)).toEqual(4);
});
});
describe('When a beforeAll has errored', function() {
it('skips subsequent functions other than afterAll', function() {
const suite = {};
const fns = [
{ type: 'beforeAll', fn: () => {}, suite },
{ fn: () => {} },
{ fn: () => {} },
{ type: 'afterAll', fn: () => {} },
{ type: 'afterAll', fn: () => {} }
];
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
policy.fnErrored(0);
expect(policy.skipTo(0)).toEqual(3);
expect(policy.skipTo(3)).toEqual(4);
});
});
});
describe('#fnErrored', function() {
describe('When the fn is a beforeAll', function() {
it("sets the suite's hadBeforeAllFailure property to true", function() {
const suite = {};
const fns = [{ type: 'beforeAll', fn: () => {}, suite }];
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
policy.fnErrored(0);
expect(suite.hadBeforeAllFailure).toBeTrue();
});
});
describe('When the fn is not a beforeAll', function() {
it('does not try to access the suite, which is probably not there', function() {
const fns = [{ fn: () => {} /* no suite */ }];
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
expect(() => policy.fnErrored(0)).not.toThrow();
});
});
});
});
function arrayOfArbitraryFns(n) {
const result = [];
for (let i = 0; i < n; i++) {
result.push({ fn: () => {} });
}
return result;
}

View File

@@ -61,10 +61,6 @@ describe('Spec', function() {
spec.execute();
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
// TODO: due to some issue with the Pretty Printer, this line fails, but the other two pass.
// This means toHaveBeenCalledWith on IE8 will always be broken.
// expect(startCallback).toHaveBeenCalledWith(spec);
expect(startCallback).toHaveBeenCalled();
expect(startCallback.calls.first().object).toEqual(spec);
});
@@ -120,9 +116,13 @@ describe('Spec', function() {
expect(options.queueableFns).toEqual([
{ fn: jasmine.any(Function) },
before,
queueableFn
queueableFn,
after,
{
fn: jasmine.any(Function),
type: 'specCleanup'
}
]);
expect(options.cleanupFns).toEqual([after, { fn: jasmine.any(Function) }]);
});
it("tells the queue runner that it's a leaf node", function() {
@@ -175,8 +175,13 @@ describe('Spec', function() {
expect(fakeQueueRunner).toHaveBeenCalledWith(
jasmine.objectContaining({
onComplete: jasmine.any(Function),
queueableFns: [{ fn: jasmine.any(Function) }],
cleanupFns: [{ fn: jasmine.any(Function) }]
queueableFns: [
{ fn: jasmine.any(Function) },
{
fn: jasmine.any(Function),
type: 'specCleanup'
}
]
})
);
expect(specBody).not.toHaveBeenCalled();
@@ -184,7 +189,7 @@ describe('Spec', function() {
var args = fakeQueueRunner.calls.mostRecent().args[0];
args.queueableFns[0].fn();
expect(startCallback).toHaveBeenCalled();
args.cleanupFns[0].fn();
args.queueableFns[args.queueableFns.length - 1].fn();
expect(resultCallback).toHaveBeenCalled();
expect(spec.result.status).toBe('excluded');
@@ -216,7 +221,7 @@ describe('Spec', function() {
var args = fakeQueueRunner.calls.mostRecent().args[0];
args.queueableFns[0].fn();
expect(startCallback).toHaveBeenCalled();
args.cleanupFns[0].fn('things');
args.queueableFns[1].fn('things');
expect(resultCallback).toHaveBeenCalledWith(
{
id: spec.id,
@@ -228,7 +233,8 @@ describe('Spec', function() {
deprecationWarnings: [],
pendingReason: '',
duration: jasmine.any(Number),
properties: null
properties: null,
debugLogs: null
},
'things'
);
@@ -287,9 +293,6 @@ describe('Spec', function() {
config.queueableFns.forEach(function(qf) {
qf.fn();
});
config.cleanupFns.forEach(function(qf) {
qf.fn();
});
config.onComplete();
},
timer: timer
@@ -357,7 +360,9 @@ describe('Spec', function() {
spec.execute();
fakeQueueRunner.calls.mostRecent().args[0].cleanupFns[0].fn();
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
fns[fns.length - 1].fn();
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual([
'expectation1'
]);
@@ -386,7 +391,8 @@ describe('Spec', function() {
spec.execute();
fakeQueueRunner.calls.mostRecent().args[0].cleanupFns[0].fn();
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
fns[fns.length - 1].fn();
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual([
'passed'
]);
@@ -485,7 +491,7 @@ describe('Spec', function() {
spec.execute();
var args = fakeQueueRunner.calls.mostRecent().args[0];
args.cleanupFns[0].fn();
args.queueableFns[args.queueableFns.length - 1].fn();
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([
{
error: 'foo',
@@ -513,7 +519,140 @@ describe('Spec', function() {
spec.execute();
var args = fakeQueueRunner.calls.mostRecent().args[0];
args.cleanupFns[0].fn();
args.queueableFns[args.queueableFns.length - 1].fn();
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
});
it('treats multiple done calls as late errors', function() {
var queueRunnerFactory = jasmine.createSpy('queueRunnerFactory'),
onLateError = jasmine.createSpy('onLateError'),
spec = new jasmineUnderTest.Spec({
onLateError: onLateError,
queueableFn: { fn: function() {} },
queueRunnerFactory: queueRunnerFactory,
getSpecName: function() {
return 'a spec';
}
});
spec.execute();
expect(queueRunnerFactory).toHaveBeenCalled();
queueRunnerFactory.calls.argsFor(0)[0].onMultipleDone();
expect(onLateError).toHaveBeenCalledTimes(1);
expect(onLateError.calls.argsFor(0)[0]).toBeInstanceOf(Error);
expect(onLateError.calls.argsFor(0)[0].message).toEqual(
'An asynchronous spec, beforeEach, or afterEach function called its ' +
"'done' callback more than once.\n(in spec: a spec)"
);
});
describe('#trace', function() {
it('adds the messages to the result', function() {
var timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
spec = new jasmineUnderTest.Spec({
queueableFn: {
fn: function() {}
},
queueRunnerFactory: function() {},
timer: timer
}),
t1 = 123,
t2 = 456;
spec.execute();
expect(spec.result.debugLogs).toBeNull();
timer.elapsed.and.returnValue(t1);
spec.debugLog('msg 1');
expect(spec.result.debugLogs).toEqual([
{ message: 'msg 1', timestamp: t1 }
]);
timer.elapsed.and.returnValue(t2);
spec.debugLog('msg 2');
expect(spec.result.debugLogs).toEqual([
{ message: 'msg 1', timestamp: t1 },
{ message: 'msg 2', timestamp: t2 }
]);
});
describe('When the spec passes', function() {
it('omits the messages from the reported result', function() {
var resultCallback = jasmine.createSpy('resultCallback'),
spec = new jasmineUnderTest.Spec({
queueableFn: {
fn: function() {}
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.debugLog('msg');
for (const fn of config.queueableFns) {
fn.fn();
}
config.onComplete(false);
}
});
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalledWith(
jasmine.objectContaining({ debugLogs: null }),
undefined
);
});
it('removes the messages to save memory', function() {
var resultCallback = jasmine.createSpy('resultCallback'),
spec = new jasmineUnderTest.Spec({
queueableFn: {
fn: function() {}
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.debugLog('msg');
for (const fn of config.queueableFns) {
fn.fn();
}
config.onComplete(false);
}
});
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalled();
expect(spec.result.debugLogs).toBeNull();
});
});
describe('When the spec fails', function() {
it('includes the messages in the reported result', function() {
var resultCallback = jasmine.createSpy('resultCallback'),
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
spec = new jasmineUnderTest.Spec({
queueableFn: {
fn: function() {}
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.debugLog('msg');
spec.onException(new Error('nope'));
for (const fn of config.queueableFns) {
fn.fn();
}
config.onComplete(true);
},
timer: timer
}),
timestamp = 12345;
timer.elapsed.and.returnValue(timestamp);
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalledWith(
jasmine.objectContaining({
debugLogs: [{ message: 'msg', timestamp: timestamp }]
}),
undefined
);
});
});
});
});

View File

@@ -407,6 +407,123 @@ describe('SpyRegistry', function() {
expect(subject.toString).not.toBe('I am a spy');
expect(subject.hasOwnProperty).not.toBe('I am a spy');
});
describe('when includeNonEnumerable is true', function() {
it('does not override Object.prototype methods', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subject = {
spied1: function() {}
};
spyRegistry.spyOnAllFunctions(subject, true);
expect(subject.spied1).toBe('I am a spy');
expect(subject.toString).not.toBe('I am a spy');
expect(subject.hasOwnProperty).not.toBe('I am a spy');
});
it('overrides non-enumerable properties', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subject = {
spied1: function() {},
spied2: function() {}
};
Object.defineProperty(subject, 'spied2', {
enumerable: false,
writable: true,
configurable: true
});
spyRegistry.spyOnAllFunctions(subject, true);
expect(subject.spied1).toBe('I am a spy');
expect(subject.spied2).toBe('I am a spy');
});
it('should not spy on non-enumerable functions named constructor', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subject = {
constructor: function() {}
};
Object.defineProperty(subject, 'constructor', {
enumerable: false,
writable: true,
configurable: true
});
spyRegistry.spyOnAllFunctions(subject, true);
expect(subject.constructor).not.toBe('I am a spy');
});
it('should spy on enumerable functions named constructor', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subject = {
constructor: function() {}
};
spyRegistry.spyOnAllFunctions(subject, true);
expect(subject.constructor).toBe('I am a spy');
});
it('should not throw an exception if we try and access strict mode restricted properties', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subject = function() {};
var fn = function() {
spyRegistry.spyOnAllFunctions(subject, true);
};
expect(fn).not.toThrow();
});
it('should not spy on properties which are more permissable further up the prototype chain', function() {
var spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: function() {
return 'I am a spy';
}
});
var subjectParent = Object.defineProperty({}, 'sharedProp', {
value: function() {},
writable: true,
configurable: true
});
var subject = Object.create(subjectParent);
Object.defineProperty(subject, 'sharedProp', {
value: function() {}
});
var fn = function() {
spyRegistry.spyOnAllFunctions(subject, true);
};
expect(fn).not.toThrow();
expect(subject).not.toBe('I am a spy');
});
});
});
describe('#clearSpies', function() {

View File

@@ -31,12 +31,7 @@ describe('Spies', function() {
var fn = function test() {};
var spy = env.createSpy(fn);
// IE doesn't do `.name`
if (fn.name === 'test') {
expect(spy.and.identity).toEqual('test');
} else {
expect(spy.and.identity).toEqual('unknown');
}
expect(spy.and.identity).toEqual('test');
});
it('warns the user that we intend to overwrite an existing property', function() {
@@ -213,7 +208,7 @@ describe('Spies', function() {
).toBe(1);
});
it('allows base name to be ommitted when assigning methods and properties', function() {
it('allows base name to be omitted when assigning methods and properties', function() {
var spyObj = env.createSpyObj({ m: 3 }, { p: 4 });
expect(spyObj.m()).toEqual(3);
@@ -236,7 +231,7 @@ describe('Spies', function() {
expect(spy('baz', 'grault', 'waldo')).toEqual(42);
});
it('uses custom equality testers when selecting a strategy', function() {
it('uses asymmetric equality testers when selecting a strategy', function() {
var spy = env.createSpy('foo');
spy.and.returnValue(42);
spy.withArgs(jasmineUnderTest.any(String)).and.returnValue(-1);
@@ -245,6 +240,23 @@ describe('Spies', function() {
expect(spy({})).toEqual(42);
});
it('uses the provided matchersUtil selecting a strategy', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [
function(a, b) {
if ((a === 'bar' && b === 'baz') || (a === 'baz' && b === 'bar')) {
return true;
}
}
]
});
const spy = new jasmineUnderTest.Spy('aSpy', matchersUtil);
spy.and.returnValue('default strategy return value');
spy.withArgs('bar').and.returnValue('custom strategy return value');
expect(spy('foo')).toEqual('default strategy return value');
expect(spy('baz')).toEqual('custom strategy return value');
});
it('can reconfigure an argument-specific strategy', function() {
var spy = env.createSpy('foo');
spy.withArgs('foo').and.returnValue(42);
@@ -253,9 +265,7 @@ describe('Spies', function() {
});
describe('any promise-based strategy', function() {
it('works with global Promise library when available', function(done) {
jasmine.getEnv().requirePromises();
it('works with global Promise library', function(done) {
var spy = env.createSpy('foo').and.resolveTo(42);
spy()
.then(function(result) {
@@ -264,19 +274,6 @@ describe('Spies', function() {
})
.catch(done.fail);
});
it('works with a custom Promise library', function() {
var customPromise = {
resolve: jasmine.createSpy(),
reject: jasmine.createSpy()
};
customPromise.resolve.and.returnValue('resolved');
env.configure({ Promise: customPromise });
var spy = env.createSpy('foo').and.resolveTo(42);
expect(spy()).toEqual('resolved');
expect(customPromise.resolve).toHaveBeenCalledWith(42);
});
});
describe('when withArgs is used without a base strategy', function() {

View File

@@ -90,7 +90,7 @@ describe('SpyStrategy', function() {
expect(function() {
spyStrategy.exec();
}).toThrow({ code: 'ESRCH' });
}).toThrow(jasmine.objectContaining({ code: 'ESRCH' }));
expect(originalFn).not.toHaveBeenCalled();
});
@@ -108,7 +108,6 @@ describe('SpyStrategy', function() {
});
it('allows a fake async function to be called instead', function(done) {
jasmine.getEnv().requireAsyncAwait();
var originalFn = jasmine.createSpy('original'),
fakeFn = jasmine
.createSpy('fake')
@@ -131,15 +130,9 @@ describe('SpyStrategy', function() {
describe('#resolveTo', function() {
it('allows a resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
},
spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn,
getPromise: getPromise
fn: originalFn
});
spyStrategy.resolveTo(37);
@@ -153,15 +146,9 @@ describe('SpyStrategy', function() {
});
it('allows an empty resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
},
spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn,
getPromise: getPromise
fn: originalFn
});
spyStrategy.resolveTo();
@@ -173,30 +160,13 @@ describe('SpyStrategy', function() {
})
.catch(done.fail);
});
it('fails if promises are not available', function() {
var originalFn = jasmine.createSpy('original'),
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
expect(function() {
spyStrategy.resolveTo(37);
}).toThrowError(
'resolveTo requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'
);
});
});
describe('#rejectWith', function() {
it('allows a rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
},
spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn,
getPromise: getPromise
fn: originalFn
});
spyStrategy.rejectWith(new Error('oops'));
@@ -211,15 +181,9 @@ describe('SpyStrategy', function() {
});
it('allows an empty rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
},
spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn,
getPromise: getPromise
fn: originalFn
});
spyStrategy.rejectWith();
@@ -234,15 +198,9 @@ describe('SpyStrategy', function() {
});
it('allows a non-Error to be rejected', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
},
spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn,
getPromise: getPromise
fn: originalFn
});
spyStrategy.rejectWith('oops');
@@ -255,17 +213,6 @@ describe('SpyStrategy', function() {
})
.catch(done.fail);
});
it('fails if promises are not available', function() {
var originalFn = jasmine.createSpy('original'),
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
expect(function() {
spyStrategy.rejectWith(new Error('oops'));
}).toThrowError(
'rejectWith requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'
);
});
});
it('allows a custom strategy to be used', function() {
@@ -335,9 +282,9 @@ describe('SpyStrategy', function() {
});
it('allows generator functions to be passed to callFake strategy', function() {
jasmine.getEnv().requireGeneratorFunctions();
var generator = jasmine.getEnv().makeGeneratorFunction('yield "ok";'),
var generator = function*() {
yield 'ok';
},
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} });
spyStrategy.callFake(generator);

View File

@@ -1,5 +1,5 @@
describe('StackTrace', function() {
it('understands Chrome/IE/Edge style traces', function() {
it('understands Chrome/Edge style traces', function() {
var error = {
message: 'nope',
stack:
@@ -30,7 +30,7 @@ describe('StackTrace', function() {
]);
});
it('understands Chrome/IE/Edge style traces with multiline messages', function() {
it('understands Chrome/Edge style traces with multiline messages', function() {
var error = {
message: 'line 1\nline 2',
stack:
@@ -95,7 +95,7 @@ describe('StackTrace', function() {
]);
});
it('understands Safari/Firefox/Phantom-OS X style traces', function() {
it('understands Safari <=14/Firefox/Phantom-OS X style traces', function() {
var error = {
message: 'nope',
stack:
@@ -122,6 +122,33 @@ describe('StackTrace', function() {
]);
});
it('understands Safari 15 style traces', function() {
var error = {
message: 'nope',
stack:
'@http://localhost:8888/__spec__/core/FooSpec.js:164:24\n' +
'attempt@http://localhost:8888/__jasmine__/jasmine.js:8074:44\n'
};
var result = new jasmineUnderTest.StackTrace(error);
expect(result.message).toBeFalsy();
expect(result.style).toEqual('webkit');
expect(result.frames).toEqual([
{
raw: '@http://localhost:8888/__spec__/core/FooSpec.js:164:24',
func: undefined,
file: 'http://localhost:8888/__spec__/core/FooSpec.js',
line: 164
},
{
raw: 'attempt@http://localhost:8888/__jasmine__/jasmine.js:8074:44',
func: 'attempt',
file: 'http://localhost:8888/__jasmine__/jasmine.js',
line: 8074
}
]);
});
it('does not mistake gibberish for Safari/Firefox/Phantom-OS X style traces', function() {
var error = {
message: 'nope',

View File

@@ -43,32 +43,83 @@ describe('Suite', function() {
expect(suite.getFullName()).toEqual('I am a parent suite I am a suite');
});
it('adds before functions in order of needed execution', function() {
it('adds beforeEach functions in order of needed execution', function() {
var suite = new jasmineUnderTest.Suite({
env: env,
description: 'I am a suite'
}),
outerBefore = jasmine.createSpy('outerBeforeEach'),
innerBefore = jasmine.createSpy('insideBeforeEach');
outerBefore = { fn: 'outerBeforeEach' },
innerBefore = { fn: 'insideBeforeEach' };
suite.beforeEach(outerBefore);
suite.beforeEach(innerBefore);
expect(suite.beforeFns).toEqual([innerBefore, outerBefore]);
expect(suite.beforeFns).toEqual([
{ fn: innerBefore.fn, suite },
{ fn: outerBefore.fn, suite }
]);
});
it('adds after functions in order of needed execution', function() {
it('adds beforeAll functions in order of needed execution', function() {
var suite = new jasmineUnderTest.Suite({
env: env,
description: 'I am a suite'
}),
outerAfter = jasmine.createSpy('outerAfterEach'),
innerAfter = jasmine.createSpy('insideAfterEach');
outerBefore = { fn: 'outerBeforeAll' },
innerBefore = { fn: 'insideBeforeAll' };
suite.beforeAll(outerBefore);
suite.beforeAll(innerBefore);
function sameInstance(expected) {
return {
asymmetricMatch: function(actual) {
return actual === expected;
},
jasmineToString: function() {
return `<same instance as ${expected}>`;
}
};
}
expect(suite.beforeAllFns).toEqual([
{ fn: outerBefore.fn, type: 'beforeAll', suite: sameInstance(suite) },
{ fn: innerBefore.fn, type: 'beforeAll', suite: sameInstance(suite) }
]);
});
it('adds afterEach functions in order of needed execution', function() {
var suite = new jasmineUnderTest.Suite({
env: env,
description: 'I am a suite'
}),
outerAfter = { fn: 'outerAfterEach' },
innerAfter = { fn: 'insideAfterEach' };
suite.afterEach(outerAfter);
suite.afterEach(innerAfter);
expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
expect(suite.afterFns).toEqual([
{ fn: innerAfter.fn, suite, type: 'afterEach' },
{ fn: outerAfter.fn, suite, type: 'afterEach' }
]);
});
it('adds afterAll functions in order of needed execution', function() {
const suite = new jasmineUnderTest.Suite({
env: env,
description: 'I am a suite'
}),
outerAfter = { fn: 'outerAfterAll' },
innerAfter = { fn: 'insideAfterAl' };
suite.afterAll(outerAfter);
suite.afterAll(innerAfter);
expect(suite.afterAllFns).toEqual([
{ fn: innerAfter.fn, type: 'afterAll' },
{ fn: outerAfter.fn, type: 'afterAll' }
]);
});
it('has a status of failed if any expectations have failed', function() {
@@ -142,4 +193,126 @@ describe('Suite', function() {
);
});
});
describe('attr.autoCleanClosures', function() {
function arrangeSuite(attrs) {
var suite = new jasmineUnderTest.Suite(attrs);
suite.beforeAll(function() {});
suite.beforeEach(function() {});
suite.afterEach(function() {});
suite.afterAll(function() {});
return suite;
}
it('should clean closures when "attr.autoCleanClosures" is missing', function() {
var suite = arrangeSuite({});
suite.cleanupBeforeAfter();
expect(suite.beforeAllFns[0].fn).toBe(null);
expect(suite.beforeFns[0].fn).toBe(null);
expect(suite.afterFns[0].fn).toBe(null);
expect(suite.afterAllFns[0].fn).toBe(null);
});
it('should clean closures when "attr.autoCleanClosures" is true', function() {
var suite = arrangeSuite({ autoCleanClosures: true });
suite.cleanupBeforeAfter();
expect(suite.beforeAllFns[0].fn).toBe(null);
expect(suite.beforeFns[0].fn).toBe(null);
expect(suite.afterFns[0].fn).toBe(null);
expect(suite.afterAllFns[0].fn).toBe(null);
});
it('should NOT clean closures when "attr.autoCleanClosures" is false', function() {
var suite = arrangeSuite({ autoCleanClosures: false });
suite.cleanupBeforeAfter();
expect(suite.beforeAllFns[0].fn).not.toBe(null);
expect(suite.beforeFns[0].fn).not.toBe(null);
expect(suite.afterFns[0].fn).not.toBe(null);
expect(suite.afterAllFns[0].fn).not.toBe(null);
});
});
describe('#reset', function() {
it('should reset the "pending" status', function() {
var suite = new jasmineUnderTest.Suite({});
suite.pend();
suite.reset();
expect(suite.getResult().status).toBe('passed');
});
it('should not reset the "pending" status when the suite was excluded', function() {
var suite = new jasmineUnderTest.Suite({});
suite.exclude();
suite.reset();
expect(suite.getResult().status).toBe('pending');
});
it('should also reset the children', function() {
var suite = new jasmineUnderTest.Suite({});
var child1 = jasmine.createSpyObj(['reset']);
var child2 = jasmine.createSpyObj(['reset']);
suite.addChild(child1);
suite.addChild(child2);
suite.reset();
expect(child1.reset).toHaveBeenCalled();
expect(child2.reset).toHaveBeenCalled();
});
it('should reset the failedExpectations', function() {
var suite = new jasmineUnderTest.Suite({
expectationResultFactory: function(error) {
return error;
}
});
suite.onException(new Error());
suite.reset();
var result = suite.getResult();
expect(result.status).toBe('passed');
expect(result.failedExpectations).toHaveSize(0);
});
});
describe('#onMultipleDone', function() {
it('reports a special error when it is the top suite', function() {
const onLateError = jasmine.createSpy('onLateError');
const suite = new jasmineUnderTest.Suite({
onLateError,
parentSuite: null
});
suite.onMultipleDone();
expect(onLateError).toHaveBeenCalledTimes(1);
expect(onLateError.calls.argsFor(0)[0]).toBeInstanceOf(Error);
expect(onLateError.calls.argsFor(0)[0].message).toEqual(
'A top-level beforeAll or afterAll function called its ' +
"'done' callback more than once."
);
});
it('reports an error including the suite name when it is a normal suite', function() {
const onLateError = jasmine.createSpy('onLateError');
var suite = new jasmineUnderTest.Suite({
onLateError,
description: 'the suite',
parentSuite: {
description: 'the parent suite',
parentSuite: {}
}
});
suite.onMultipleDone();
expect(onLateError).toHaveBeenCalledTimes(1);
expect(onLateError.calls.argsFor(0)[0]).toBeInstanceOf(Error);
expect(onLateError.calls.argsFor(0)[0].message).toEqual(
"An asynchronous beforeAll or afterAll function called its 'done' " +
'callback more than once.\n(in suite: the parent suite the suite)'
);
});
});
});

View File

@@ -14,10 +14,12 @@ describe('Timer', function() {
describe('when date is stubbed, perhaps by other testing helpers', function() {
var origDate = Date;
beforeEach(function() {
// eslint-disable-next-line no-implicit-globals
Date = jasmine.createSpy('date spy');
});
afterEach(function() {
// eslint-disable-next-line no-implicit-globals
Date = origDate;
});

View File

@@ -291,7 +291,8 @@ describe('TreeProcessor', function() {
onComplete: treeComplete,
onException: jasmine.any(Function),
userContext: { root: 'context' },
queueableFns: [{ fn: jasmine.any(Function) }]
queueableFns: [{ fn: jasmine.any(Function) }],
onMultipleDone: null
});
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
@@ -321,16 +322,19 @@ describe('TreeProcessor', function() {
onComplete: treeComplete,
onException: jasmine.any(Function),
userContext: { root: 'context' },
queueableFns: [{ fn: jasmine.any(Function) }]
queueableFns: [{ fn: jasmine.any(Function) }],
onMultipleDone: null
});
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn(nodeDone);
expect(queueRunner).toHaveBeenCalledWith({
onComplete: jasmine.any(Function),
onMultipleDone: null,
queueableFns: [{ fn: jasmine.any(Function) }],
userContext: { node: 'context' },
onException: jasmine.any(Function)
onException: jasmine.any(Function),
onMultipleDone: null
});
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
@@ -478,7 +482,10 @@ describe('TreeProcessor', function() {
var leaf = new Leaf(),
node = new Node({
children: [leaf],
beforeAllFns: ['beforeAll1', 'beforeAll2']
beforeAllFns: [
{ fn: 'beforeAll1', timeout: 1 },
{ fn: 'beforeAll2', timeout: 2 }
]
}),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
@@ -498,17 +505,18 @@ describe('TreeProcessor', function() {
expect(queueableFns).toEqual([
{ fn: jasmine.any(Function) },
'beforeAll1',
'beforeAll2',
{ fn: 'beforeAll1', timeout: 1 },
{ fn: 'beforeAll2', timeout: 2 },
{ fn: jasmine.any(Function) }
]);
});
it('runs afterAlls for a node with children', function() {
var leaf = new Leaf(),
afterAllFns = [{ fn: 'afterAll1' }, { fn: 'afterAll2' }],
node = new Node({
children: [leaf],
afterAllFns: ['afterAll1', 'afterAll2']
afterAllFns
}),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
@@ -529,15 +537,15 @@ describe('TreeProcessor', function() {
expect(queueableFns).toEqual([
{ fn: jasmine.any(Function) },
{ fn: jasmine.any(Function) },
'afterAll1',
'afterAll2'
afterAllFns[0],
afterAllFns[1]
]);
});
it('does not run beforeAlls or afterAlls for a node with no children', function() {
var node = new Node({
beforeAllFns: ['before'],
afterAllFns: ['after']
beforeAllFns: [{ fn: 'before' }],
afterAllFns: [{ fn: 'after' }]
}),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
@@ -562,8 +570,8 @@ describe('TreeProcessor', function() {
var leaf = new Leaf({ markedPending: true }),
node = new Node({
children: [leaf],
beforeAllFns: ['before'],
afterAllFns: ['after'],
beforeAllFns: [{ fn: 'before' }],
afterAllFns: [{ fn: 'after' }],
markedPending: false
}),
root = new Node({ children: [node] }),

View File

@@ -39,8 +39,7 @@ describe('jasmineUnderTest.util', function() {
};
beforeEach(function() {
jasmine.getEnv().requirePromises();
mockNativePromise = new Promise(function(res, rej) {}); // eslint-disable-line compat/compat
mockNativePromise = new Promise(function(res, rej) {});
mockPromiseLikeObject = new mockPromiseLike();
});

View File

@@ -1,140 +0,0 @@
describe('asymmetricEqualityTesterArgCompatShim', function() {
it('provides all the properties of the MatchersUtil', function() {
var matchersUtil = {
foo: function() {},
bar: function() {}
},
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
matchersUtil,
[]
);
expect(shim.foo).toBe(matchersUtil.foo);
expect(shim.bar).toBe(matchersUtil.bar);
});
it('provides all the properties of the customEqualityTesters', function() {
var customEqualityTesters = [function() {}, function() {}],
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
{},
customEqualityTesters
);
expect(shim.length).toBe(2);
expect(shim[0]).toBe(customEqualityTesters[0]);
expect(shim[1]).toBe(customEqualityTesters[1]);
});
it('provides all the properties of Array.prototype', function() {
var shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []);
expect(shim.filter).toBe(Array.prototype.filter);
expect(shim.forEach).toBe(Array.prototype.forEach);
expect(shim.map).toBe(Array.prototype.map);
});
it('provides properties of Array.prototype', function() {
var keys = [
'concat',
'every',
'filter',
'forEach',
'indexOf',
'join',
'lastIndexOf',
'length',
'map',
'pop',
'push',
'reduce',
'reduceRight',
'reverse',
'shift',
'slice',
'some',
'sort',
'splice',
'unshift'
],
optionalKeys = [
'copyWithin',
'entries',
'fill',
'find',
'findIndex',
'flat',
'flatMap',
'includes',
'keys',
'toSource',
'values'
],
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []),
i,
k;
// Properties that are present on all supported runtimes
for (i = 0; i < keys.length; i++) {
k = keys[i];
expect(shim[k])
.withContext(k)
.not.toBeUndefined();
expect(shim[k])
.withContext(k)
.toBe(Array.prototype[k]);
}
// Properties that are present on only some supported runtimes
for (i = 0; i < optionalKeys.length; i++) {
k = optionalKeys[i];
if (shim[k] !== undefined) {
expect(shim[k])
.withContext(k)
.toBe(Array.prototype[k]);
}
}
});
describe('When Array.prototype additions collide with MatchersUtil methods', function() {
function keys() {
return [
'contains',
'buildFailureMessage',
'asymmetricDiff_',
'asymmetricMatch_',
'equals',
'eq_'
];
}
beforeEach(function() {
keys().forEach(function(k) {
expect(Array.prototype[k])
.withContext('Array.prototype already had ' + k)
.toBeUndefined();
Array.prototype[k] = function() {};
});
});
afterEach(function() {
keys().forEach(function(k) {
delete Array.prototype[k];
});
});
it('uses the MatchersUtil methods', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({}),
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
matchersUtil,
[]
);
keys().forEach(function(k) {
expect(shim[k])
.withContext(k + ' was overwritten')
.toBe(jasmineUnderTest.MatchersUtil.prototype[k]);
});
});
});
});

View File

@@ -30,35 +30,27 @@ describe('Any', function() {
});
it('matches a Map', function() {
jasmine.getEnv().requireFunctioningMaps();
var any = new jasmineUnderTest.Any(Map);
expect(any.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(new Map())).toBe(true);
});
it('matches a Set', function() {
jasmine.getEnv().requireFunctioningSets();
var any = new jasmineUnderTest.Any(Set);
expect(any.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(new Set())).toBe(true);
});
it('matches a TypedArray', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var any = new jasmineUnderTest.Any(Uint32Array);
var any = new jasmineUnderTest.Any(Uint32Array); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true);
});
it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
var any = new jasmineUnderTest.Any(Symbol);
var any = new jasmineUnderTest.Any(Symbol); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(Symbol())).toBe(true);
});
it('matches another constructed object', function() {

View File

@@ -24,35 +24,27 @@ describe('Anything', function() {
});
it('matches a Map', function() {
jasmine.getEnv().requireFunctioningMaps();
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat
expect(anything.asymmetricMatch(new Map())).toBe(true);
});
it('matches a Set', function() {
jasmine.getEnv().requireFunctioningSets();
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat
expect(anything.asymmetricMatch(new Set())).toBe(true);
});
it('matches a TypedArray', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true);
});
it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat
expect(anything.asymmetricMatch(Symbol())).toBe(true);
});
it("doesn't match undefined", function() {

View File

@@ -22,30 +22,27 @@ describe('Empty', function() {
});
it('matches an empty map', function() {
jasmine.getEnv().requireFunctioningMaps();
var empty = new jasmineUnderTest.Empty();
var fullMap = new Map(); // eslint-disable-line compat/compat
var fullMap = new Map();
fullMap.set('thing', 2);
expect(empty.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat
expect(empty.asymmetricMatch(new Map())).toBe(true);
expect(empty.asymmetricMatch(fullMap)).toBe(false);
});
it('matches an empty set', function() {
jasmine.getEnv().requireFunctioningSets();
var empty = new jasmineUnderTest.Empty();
var fullSet = new Set(); // eslint-disable-line compat/compat
var fullSet = new Set();
fullSet.add(3);
expect(empty.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat
expect(empty.asymmetricMatch(new Set())).toBe(true);
expect(empty.asymmetricMatch(fullSet)).toBe(false);
});
it('matches an empty typed array', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var empty = new jasmineUnderTest.Empty();
expect(empty.asymmetricMatch(new Int16Array())).toBe(true); // eslint-disable-line compat/compat
expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false); // eslint-disable-line compat/compat
expect(empty.asymmetricMatch(new Int16Array())).toBe(true);
expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false);
});
});

View File

@@ -1,33 +1,19 @@
/* eslint-disable compat/compat */
describe('MapContaining', function() {
function MapI(iterable) {
// for IE11
var map = new Map();
iterable.forEach(function(kv) {
map.set(kv[0], kv[1]);
});
return map;
}
beforeEach(function() {
jasmine.getEnv().requireFunctioningMaps();
});
it('matches any actual map to an empty map', function() {
var actualMap = new MapI([['foo', 'bar']]);
var actualMap = new Map([['foo', 'bar']]);
var containing = new jasmineUnderTest.MapContaining(new Map());
expect(containing.asymmetricMatch(actualMap)).toBe(true);
});
it('matches when all the key/value pairs in sample have matches in actual', function() {
var actualMap = new MapI([
var actualMap = new Map([
['foo', [1, 2, 3]],
[{ foo: 'bar' }, 'baz'],
['other', 'any']
]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -35,12 +21,12 @@ describe('MapContaining', function() {
});
it('does not match when a key is not in actual', function() {
var actualMap = new MapI([
var actualMap = new Map([
['foo', [1, 2, 3]],
[{ foo: 'not a bar' }, 'baz']
]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -48,9 +34,9 @@ describe('MapContaining', function() {
});
it('does not match when a value is not in actual', function() {
var actualMap = new MapI([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
var actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -58,13 +44,13 @@ describe('MapContaining', function() {
});
it('matches when all the key/value pairs in sample have asymmetric matches in actual', function() {
var actualMap = new MapI([
var actualMap = new Map([
['foo1', 'not a bar'],
['foo2', 'bar'],
['baz', [1, 2, 3, 4]]
]);
var containingMap = new MapI([
var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
@@ -75,9 +61,9 @@ describe('MapContaining', function() {
});
it('does not match when a key in sample has no asymmetric matches in actual', function() {
var actualMap = new MapI([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var actualMap = new Map([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([
var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
@@ -88,9 +74,9 @@ describe('MapContaining', function() {
});
it('does not match when a value in sample has no asymmetric matches in actual', function() {
var actualMap = new MapI([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var actualMap = new Map([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([
var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([4, 5])]
]);
@@ -101,15 +87,15 @@ describe('MapContaining', function() {
});
it('matches recursively', function() {
var actualMap = new MapI([
['foo', new MapI([['foo1', 1], ['foo2', 2]])],
[new MapI([[1, 'bar1'], [2, 'bar2']]), 'bar'],
var actualMap = new Map([
['foo', new Map([['foo1', 1], ['foo2', 2]])],
[new Map([[1, 'bar1'], [2, 'bar2']]), 'bar'],
['other', 'any']
]);
var containingMap = new MapI([
['foo', new jasmineUnderTest.MapContaining(new MapI([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new MapI([[2, 'bar2']])), 'bar']
var containingMap = new Map([
['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -124,10 +110,8 @@ describe('MapContaining', function() {
? a < 0 && b < 0
: a === b;
}
var actualMap = new MapI([['foo', -1]]);
var containing = new jasmineUnderTest.MapContaining(
new MapI([['foo', -2]])
);
var actualMap = new Map([['foo', -1]]);
var containing = new jasmineUnderTest.MapContaining(new Map([['foo', -2]]));
var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -136,7 +120,7 @@ describe('MapContaining', function() {
});
it('does not match when actual is not a map', function() {
var containingMap = new MapI([['foo', 'bar']]);
var containingMap = new Map([['foo', 'bar']]);
expect(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
).toBe(false);

View File

@@ -22,32 +22,29 @@ describe('NotEmpty', function() {
});
it('matches a non empty map', function() {
jasmine.getEnv().requireFunctioningMaps();
var notEmpty = new jasmineUnderTest.NotEmpty();
var fullMap = new Map(); // eslint-disable-line compat/compat
var fullMap = new Map();
fullMap.set('one', 1);
var emptyMap = new Map(); // eslint-disable-line compat/compat
var emptyMap = new Map();
expect(notEmpty.asymmetricMatch(fullMap)).toBe(true);
expect(notEmpty.asymmetricMatch(emptyMap)).toBe(false);
});
it('matches a non empty set', function() {
jasmine.getEnv().requireFunctioningSets();
var notEmpty = new jasmineUnderTest.NotEmpty();
var filledSet = new Set(); // eslint-disable-line compat/compat
var filledSet = new Set();
filledSet.add(1);
var emptySet = new Set(); // eslint-disable-line compat/compat
var emptySet = new Set();
expect(notEmpty.asymmetricMatch(filledSet)).toBe(true);
expect(notEmpty.asymmetricMatch(emptySet)).toBe(false);
});
it('matches a non empty typed array', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var notEmpty = new jasmineUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true); // eslint-disable-line compat/compat
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); // eslint-disable-line compat/compat
expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true);
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false);
});
});

View File

@@ -110,16 +110,7 @@ describe('ObjectContaining', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var prototypeObject = { foo: 'fooVal' };
var obj;
if (Object.create) {
obj = Object.create(prototypeObject);
} else {
function Foo() {}
Foo.prototype = prototypeObject;
Foo.prototype.constructor = Foo;
obj = new Foo();
}
var obj = Object.create(prototypeObject);
expect(containing.asymmetricMatch(obj, matchersUtil)).toBe(true);
});

View File

@@ -1,29 +1,15 @@
/* eslint-disable compat/compat */
describe('SetContaining', function() {
function SetI(iterable) {
// for IE11
var set = new Set();
iterable.forEach(function(v) {
set.add(v);
});
return set;
}
beforeEach(function() {
jasmine.getEnv().requireFunctioningSets();
});
it('matches any actual set to an empty set', function() {
var actualSet = new SetI(['foo', 'bar']);
var actualSet = new Set(['foo', 'bar']);
var containing = new jasmineUnderTest.SetContaining(new Set());
expect(containing.asymmetricMatch(actualSet)).toBe(true);
});
it('matches when all the values in sample have matches in actual', function() {
var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var containingSet = new SetI([[1, 2, 3], { foo: 'bar' }]);
var containingSet = new Set([[1, 2, 3], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -31,9 +17,9 @@ describe('SetContaining', function() {
});
it('does not match when a value is not in actual', function() {
var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var containingSet = new SetI([[1, 2], { foo: 'bar' }]);
var containingSet = new Set([[1, 2], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -41,9 +27,9 @@ describe('SetContaining', function() {
});
it('matches when all the values in sample have asymmetric matches in actual', function() {
var actualSet = new SetI([[1, 2, 3, 4], 'other', 'foo1']);
var actualSet = new Set([[1, 2, 3, 4], 'other', 'foo1']);
var containingSet = new SetI([
var containingSet = new Set([
jasmineUnderTest.stringMatching(/^foo\d/),
jasmineUnderTest.arrayContaining([2, 3])
]);
@@ -54,9 +40,9 @@ describe('SetContaining', function() {
});
it('does not match when a value in sample has no asymmetric matches in actual', function() {
var actualSet = new SetI(['a-foo1', [1, 2, 3, 4], 'other']);
var actualSet = new Set(['a-foo1', [1, 2, 3, 4], 'other']);
var containingSet = new SetI([
var containingSet = new Set([
jasmine.stringMatching(/^foo\d/),
jasmine.arrayContaining([2, 3])
]);
@@ -67,10 +53,10 @@ describe('SetContaining', function() {
});
it('matches recursively', function() {
var actualSet = new SetI(['foo', new SetI([1, 'bar', 2]), 'other']);
var actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']);
var containingSet = new SetI([
new jasmineUnderTest.SetContaining(new SetI(['bar'])),
var containingSet = new Set([
new jasmineUnderTest.SetContaining(new Set(['bar'])),
'foo'
]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
@@ -86,8 +72,8 @@ describe('SetContaining', function() {
? a < 0 && b < 0
: a === b;
}
var actualSet = new SetI(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new SetI([-2, 'foo']));
var actualSet = new Set(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo']));
var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -96,7 +82,7 @@ describe('SetContaining', function() {
});
it('does not match when actual is not a set', function() {
var containingSet = new SetI(['foo']);
var containingSet = new Set(['foo']);
expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
).toBe(false);

View File

@@ -0,0 +1,27 @@
describe('StringContaining', function() {
it('searches for a provided substring when the expected is a String', function() {
var matcher = new jasmineUnderTest.StringContaining('foo');
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
});
it('raises an Error when the expected is not a String', function() {
expect(function() {
new jasmineUnderTest.StringContaining(/foo/);
}).toThrowError(/not a String/);
});
it('fails when the actual is not a String', function() {
var matcher = new jasmineUnderTest.StringContaining('x');
expect(matcher.asymmetricMatch(['x'])).toBe(false);
});
it("jasmineToString's itself", function() {
var matching = new jasmineUnderTest.StringContaining('foo');
expect(matching.jasmineToString()).toEqual(
'<jasmine.stringContaining("foo")>'
);
});
});

View File

@@ -29,6 +29,43 @@ describe('base helpers', function() {
}
}, 100);
});
it('returns true for an Error subclass', function() {
function MyError() {}
MyError.prototype = new Error();
expect(jasmineUnderTest.isError_(new MyError())).toBe(true);
});
it('returns true for an un-thrown Error with no message in this environment', function() {
expect(jasmineUnderTest.isError_(new Error())).toBe(true);
});
it('returns true for an Error that originated from another frame', function() {
var iframe, error;
if (typeof window === 'undefined') {
pending('This test only runs in browsers.');
}
iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
try {
error = iframe.contentWindow.eval('new Error()');
expect(jasmineUnderTest.isError_(error)).toBe(true);
} finally {
document.body.removeChild(iframe);
}
});
it('returns false for a falsy value', function() {
expect(jasmineUnderTest.isError_(undefined)).toBe(false);
});
it('returns false for a non-Error object', function() {
expect(jasmineUnderTest.isError_({})).toBe(false);
});
});
describe('isAsymmetricEqualityTester_', function() {
@@ -54,8 +91,7 @@ describe('base helpers', function() {
describe('isSet', function() {
it('returns true when the object is a Set', function() {
jasmine.getEnv().requireFunctioningSets();
expect(jasmineUnderTest.isSet(new Set())).toBe(true); // eslint-disable-line compat/compat
expect(jasmineUnderTest.isSet(new Set())).toBe(true);
});
it('returns false when the object is not a Set', function() {
@@ -65,14 +101,111 @@ describe('base helpers', function() {
describe('isURL', function() {
it('returns true when the object is a URL', function() {
jasmine.getEnv().requireUrls();
// eslint-disable-next-line compat/compat
expect(jasmineUnderTest.isURL(new URL('http://localhost/'))).toBe(true);
});
it('returns false when the object is not a URL', function() {
jasmine.getEnv().requireUrls();
expect(jasmineUnderTest.isURL({})).toBe(false);
});
});
describe('isIterable_', function() {
it('returns true when the object is an Array', function() {
expect(jasmineUnderTest.isIterable_([])).toBe(true);
});
it('returns true when the object is a Set', function() {
expect(jasmineUnderTest.isIterable_(new Set())).toBe(true);
});
it('returns true when the object is a Map', function() {
expect(jasmineUnderTest.isIterable_(new Map())).toBe(true);
});
it('returns true when the object implements @@iterator', function() {
const myIterable = { [Symbol.iterator]: function() {} };
expect(jasmineUnderTest.isIterable_(myIterable)).toBe(true);
});
it('returns false when the object does not implement @@iterator', function() {
expect(jasmineUnderTest.isIterable_({})).toBe(false);
});
});
describe('isPending_', function() {
it('returns a promise that resolves to true when the promise is pending', function() {
var promise = new Promise(function() {});
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
true
);
});
it('returns a promise that resolves to false when the promise is resolved', function() {
var promise = Promise.resolve();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false
);
});
it('returns a promise that resolves to false when the promise is rejected', function() {
var promise = Promise.reject();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false
);
});
});
describe('DEFAULT_TIMEOUT_INTERVAL setter', function() {
var max = 2147483647;
beforeEach(function() {
this.initialValue = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
});
afterEach(function() {
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.initialValue;
});
it('accepts only values <= ' + max, function() {
expect(function() {
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = max + 1;
}).toThrowError(
'jasmine.DEFAULT_TIMEOUT_INTERVAL cannot be greater than ' + max
);
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = max;
expect(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL).toEqual(max);
});
it('is consistent with setTimeout in this environment', function(done) {
var f1 = jasmine.createSpy('setTimeout callback for ' + max),
f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)),
id;
// Suppress printing of TimeoutOverflowWarning in node
spyOn(console, 'error');
id = setTimeout(f1, max);
setTimeout(function() {
clearTimeout(id);
expect(f1).not.toHaveBeenCalled();
id = setTimeout(f2, max + 1);
setTimeout(function() {
clearTimeout(id);
expect(f2).toHaveBeenCalled();
done();
});
});
});
});
describe('debugLog', function() {
it("forwards to the current env's debugLog function", function() {
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
jasmineUnderTest.debugLog('a message');
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
'a message'
);
});
});
});

View File

@@ -122,40 +122,24 @@ describe('Asymmetric equality testers (Integration)', function() {
});
describe('mapContaining', function() {
if (jasmine.getEnv().hasFunctioningMaps()) {
verifyPasses(function(env) {
var actual = new Map();
actual.set('a', '2');
var expected = new Map();
expected.set('a', 2);
verifyPasses(function(env) {
var actual = new Map();
actual.set('a', '2');
var expected = new Map();
expected.set('a', 2);
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(actual).toEqual(jasmineUnderTest.mapContaining(expected));
});
} else {
it('passes', function() {
jasmine
.getEnv()
.pending('Browser has incomplete or missing support for Maps');
});
}
env.expect(actual).toEqual(jasmineUnderTest.mapContaining(expected));
});
if (jasmine.getEnv().hasFunctioningMaps()) {
verifyFails(function(env) {
env
.expect('something')
.toEqual(jasmineUnderTest.mapContaining(new Map()));
});
} else {
it('fails', function() {
jasmine
.getEnv()
.pending('Browser has incomplete or missing support for Maps');
});
}
verifyFails(function(env) {
env
.expect('something')
.toEqual(jasmineUnderTest.mapContaining(new Map()));
});
});
describe('notEmpty', function() {
@@ -185,40 +169,24 @@ describe('Asymmetric equality testers (Integration)', function() {
});
describe('setContaining', function() {
if (jasmine.getEnv().hasFunctioningSets()) {
verifyPasses(function(env) {
var actual = new Set();
actual.add('1');
var expected = new Set();
actual.add(1);
verifyPasses(function(env) {
var actual = new Set();
actual.add('1');
var expected = new Set();
actual.add(1);
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(actual).toEqual(jasmineUnderTest.setContaining(expected));
});
} else {
it('pases', function() {
jasmine
.getEnv()
.pending('Browser has incomplete or missing support for Sets');
});
}
env.expect(actual).toEqual(jasmineUnderTest.setContaining(expected));
});
if (jasmine.getEnv().hasFunctioningSets()) {
verifyFails(function(env) {
env
.expect('something')
.toEqual(jasmineUnderTest.setContaining(new Set()));
});
} else {
it('fails', function() {
jasmine
.getEnv()
.pending('Browser has incomplete or missing support for Sets');
});
}
verifyFails(function(env) {
env
.expect('something')
.toEqual(jasmineUnderTest.setContaining(new Set()));
});
});
describe('stringMatching', function() {
@@ -231,6 +199,16 @@ describe('Asymmetric equality testers (Integration)', function() {
});
});
describe('stringContaining', function() {
verifyPasses(function(env) {
env.expect('foo').toEqual(jasmineUnderTest.stringContaining('o'));
});
verifyFails(function(env) {
env.expect('bar').toEqual(jasmineUnderTest.stringContaining('o'));
});
});
describe('truthy', function() {
verifyPasses(function(env) {
env.expect(true).toEqual(jasmineUnderTest.truthy());

View File

@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('Custom Async Matchers (Integration)', function() {
var env;
@@ -12,8 +11,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('passes the spec if the custom async matcher passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec using custom async matcher', function() {
env.addAsyncMatchers({
toBeReal: function() {
@@ -37,8 +34,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('uses the negative compare function for a negative comparison, if provided', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec with custom negative comparison matcher', function() {
env.addAsyncMatchers({
toBeReal: function() {
@@ -65,8 +60,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec with an expectation', function() {
env.addAsyncMatchers({
toBeReal: function() {
@@ -91,26 +84,20 @@ describe('Custom Async Matchers (Integration)', function() {
env.execute(null, done);
});
// TODO: remove this in the next major release.
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function() {
it('passes the jasmine utility to the matcher factory', function(done) {
var matcherFactory = function(util) {
return {
compare: function() {
return Promise.resolve({ pass: true });
}
};
},
matcherFactorySpy = jasmine
.createSpy('matcherFactorySpy')
.and.callFake(matcherFactory),
customEqualityFn = function() {
return true;
};
matcherFactorySpy = jasmine.createSpy(
'matcherFactorySpy',
matcherFactory
);
env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addAsyncMatchers({
toBeReal: matcherFactorySpy
});
@@ -120,8 +107,7 @@ describe('Custom Async Matchers (Integration)', function() {
var specExpectations = function() {
expect(matcherFactorySpy).toHaveBeenCalledWith(
jasmine.any(jasmineUnderTest.MatchersUtil),
[customEqualityFn]
jasmine.any(jasmineUnderTest.MatchersUtil)
);
};
@@ -130,8 +116,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(matchersUtil) {
return {
compare: function(actual, expected) {

View File

@@ -108,40 +108,6 @@ describe('Custom Matchers (Integration)', function() {
env.execute(null, done);
});
it('supports asymmetric equality testers that take a list of custom equality testers', function(done) {
// TODO: remove this in the next major release.
spyOn(jasmineUnderTest, 'getEnv').and.returnValue(env);
env.it('spec using custom asymmetric equality tester', function() {
var customEqualityFn = function(a, b) {
if (a === 2 && b === 'two') {
return true;
}
};
var arrayWithFirstElement = function(sample) {
return {
asymmetricMatch: function(actual, customEqualityTesters) {
return jasmineUnderTest.matchersUtil.equals(
sample,
actual[0],
customEqualityTesters
);
}
};
};
env.addCustomEqualityTester(customEqualityFn);
env.expect(['two']).toEqual(arrayWithFirstElement(2));
});
var specExpectations = function(result) {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('displays an appropriate failure message if a custom equality matcher fails', function(done) {
env.it('spec using custom equality matcher', function() {
var customEqualityFn = function(a, b) {
@@ -244,9 +210,8 @@ describe('Custom Matchers (Integration)', function() {
env.execute(null, done);
});
// TODO: remove this in the next major release.
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
var matcherFactory = function() {
it('passes the jasmine utility to the matcher factory', function(done) {
var matcherFactory = function(util) {
return {
compare: function() {
return { pass: true };
@@ -255,13 +220,9 @@ describe('Custom Matchers (Integration)', function() {
},
matcherFactorySpy = jasmine
.createSpy('matcherFactorySpy')
.and.callFake(matcherFactory),
customEqualityFn = function() {
return true;
};
.and.callFake(matcherFactory);
env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addMatchers({
toBeReal: matcherFactorySpy
});
@@ -271,8 +232,7 @@ describe('Custom Matchers (Integration)', function() {
var specExpectations = function() {
expect(matcherFactorySpy).toHaveBeenCalledWith(
jasmine.any(jasmineUnderTest.MatchersUtil),
[customEqualityFn]
jasmine.any(jasmineUnderTest.MatchersUtil)
);
};

View File

@@ -10,13 +10,12 @@ describe('Custom Spy Strategies (Integration)', function() {
env.cleanup_();
});
it('allows adding more strategies local to a suite', function(done) {
it('allows adding more strategies local to a suite', async function() {
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.describe('suite defining a custom spy strategy', function() {
env.beforeEach(function() {
env.beforeAll(function() {
env.addSpyStrategy('frobnicate', strategy);
});
@@ -32,20 +31,13 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute(null, expectations);
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows adding more strategies local to a spec', function(done) {
it('allows adding more strategies local to a spec', async function() {
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
@@ -59,20 +51,13 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute(null, expectations);
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows using custom strategies on a per-argument basis', function(done) {
it('allows using custom strategies on a per-argument basis', async function() {
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
@@ -92,23 +77,16 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute(null, expectations);
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows multiple custom strategies to be used', function(done) {
it('allows multiple custom strategies to be used', async function() {
var plan1 = jasmine.createSpy('plan 1').and.returnValue(42),
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
specDone = jasmine.createSpy('specDone'),
jasmineDone = jasmine.createSpy('jasmineDone');
specDone = jasmine.createSpy('specDone');
env.beforeEach(function() {
env.addSpyStrategy('frobnicate', strategy1);
@@ -133,14 +111,9 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(plan2).toHaveBeenCalled();
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
expect(specDone.calls.count()).toBe(2);
done();
}
env.addReporter({ jasmineDone: jasmineDone, specDone: specDone });
env.execute(null, expectations);
env.addReporter({ specDone: specDone });
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
expect(specDone.calls.count()).toBe(2);
});
});

View File

@@ -10,7 +10,7 @@ describe('Default Spy Strategy (Integration)', function() {
env.cleanup_();
});
it('allows defining a default spy strategy', function(done) {
it('allows defining a default spy strategy', async function() {
env.describe('suite with default strategy', function() {
env.beforeEach(function() {
env.setDefaultSpyStrategy(function(and) {
@@ -29,18 +29,11 @@ describe('Default Spy Strategy (Integration)', function() {
expect(spy()).toBeUndefined();
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
var jasmineDone = jasmine.createSpy('jasmineDone');
env.addReporter({ jasmineDone: jasmineDone });
env.execute(null, expectations);
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('uses the default spy strategy defined when the spy is created', function(done) {
it('uses the default spy strategy defined when the spy is created', async function() {
env.it('spec', function() {
var a = env.createSpy('a');
env.setDefaultSpyStrategy(function(and) {
@@ -67,14 +60,7 @@ describe('Default Spy Strategy (Integration)', function() {
expect(d.and.isConfigured()).toBe(false);
});
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
var jasmineDone = jasmine.createSpy('jasmineDone');
env.addReporter({ jasmineDone: jasmineDone });
env.execute(null, expectations);
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
});

View File

@@ -0,0 +1,322 @@
/* eslint no-console: 0 */
describe('Deprecation (integration)', function() {
var env;
beforeEach(function() {
env = new jasmineUnderTest.Env();
});
afterEach(function() {
env.cleanup_();
});
it('reports a deprecation on the top suite', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.beforeAll(function() {
env.deprecated('the message');
});
env.it('a spec', function() {});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/^DEPRECATION: the message/)
);
done();
});
});
it('reports a deprecation on a descendent suite', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
});
env.it('a spec', function() {});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in suite: a suite\)/
)
);
done();
});
});
it('reports a deprecation on a spec', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
)
);
done();
});
});
it('omits the suite or spec context when ignoreRunnable is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.it('a spec', function() {
env.deprecated('the message', { ignoreRunnable: true });
});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/the message/)
);
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/a spec/)
);
done();
});
});
it('includes the stack trace', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
stack: jasmine.stringMatching(/DeprecationSpec.js/)
})
]
})
);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0].replace(/\n/g, 'NL')).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)NL.*DeprecationSpec.js/
);
done();
});
});
it('excludes the stack trace when omitStackTrace is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message', { omitStackTrace: true });
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
stack: jasmine.falsy()
})
]
})
);
expect(console.error).toHaveBeenCalled();
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/DeprecationSpec.js/)
);
done();
});
});
it('emits a given deprecation only once', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
env.deprecated('the message');
});
env.it('a spec', function() {
env.deprecated('the message');
env.deprecated('a different message');
});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
// only one
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
// only the other one
jasmine.objectContaining({
message: jasmine.stringMatching(/^a different message/)
})
]
})
);
expect(console.error).toHaveBeenCalledTimes(2);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in suite: a suite\)/
)
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: a different message \(in spec: a suite a spec\)/
)
);
done();
});
});
it('emits a given deprecation each time when config.verboseDeprecations is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.configure({ verboseDeprecations: true });
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
env.deprecated('the message');
});
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
}),
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledTimes(3);
expect(console.error.calls.argsFor(0)[0]).toMatch(
/^DEPRECATION: the message \(in suite: a suite\)/
);
expect(console.error.calls.argsFor(1)[0]).toMatch(
/^DEPRECATION: the message \(in suite: a suite\)/
);
expect(console.error.calls.argsFor(2)[0]).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
);
expect(console.error.calls.argsFor(2)[0]).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
);
done();
});
});
it('handles deprecations that occur before execute() is called', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.deprecated('the message');
env.it('a spec', function() {});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/^DEPRECATION: the message/)
);
done();
});
});
});

View File

@@ -156,10 +156,6 @@ describe('Env integration', function() {
message: 'Failed: error message',
stack: {
asymmetricMatch: function(other) {
if (!other) {
// IE doesn't give us a stacktrace so just ignore it.
return true;
}
var split = other.split('\n'),
firstLine = split[0];
if (firstLine.indexOf('error message') >= 0) {
@@ -459,9 +455,13 @@ describe('Env integration', function() {
});
it('copes with async failures after done has been called', function(done) {
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
var global = {
setTimeout: function(fn, delay) {
setTimeout(fn, delay);
return setTimeout(fn, delay);
},
clearTimeout: function(fn, delay) {
clearTimeout(fn, delay);
@@ -509,6 +509,173 @@ describe('Env integration', function() {
env.execute(null, assertions);
});
it('reports multiple calls to done in the top suite as errors', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']);
var message =
'A top-level beforeAll or afterAll function called its ' +
"'done' callback more than once.";
env.addReporter(reporter);
env.beforeAll(function(innerDone) {
innerDone();
innerDone();
});
env.it('a spec, so the beforeAll runs', function() {});
env.afterAll(function(innerDone) {
innerDone();
innerDone();
});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalled();
const errors = reporter.jasmineDone.calls.argsFor(0)[0]
.failedExpectations;
expect(errors.length).toEqual(2);
expect(errors[0].message)
.withContext('top beforeAll')
.toContain(message);
expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('top afterAll')
.toContain(message);
expect(errors[1].globalErrorType).toEqual('lateError');
done();
});
});
it('reports multiple calls to done in a non-top suite as errors', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']);
var message =
"An asynchronous beforeAll or afterAll function called its 'done' " +
'callback more than once.\n(in suite: a suite)';
env.addReporter(reporter);
env.describe('a suite', function() {
env.beforeAll(function(innerDone) {
innerDone();
innerDone();
});
env.it('a spec, so that before/afters run', function() {});
env.afterAll(function(innerDone) {
innerDone();
innerDone();
});
});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalled();
const errors = reporter.jasmineDone.calls.argsFor(0)[0]
.failedExpectations;
expect(errors.length).toEqual(2);
expect(errors[0].message)
.withContext('suite beforeAll')
.toContain(message);
expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('suite afterAll')
.toContain(message);
expect(errors[1].globalErrorType).toEqual('lateError');
done();
});
});
it('reports multiple calls to done in a spec as errors', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']);
var message =
'An asynchronous spec, beforeEach, or afterEach function called its ' +
"'done' callback more than once.\n(in spec: a suite a spec)";
env.addReporter(reporter);
env.describe('a suite', function() {
env.beforeEach(function(innerDone) {
innerDone();
innerDone();
});
env.it('a spec', function(innerDone) {
innerDone();
innerDone();
});
env.afterEach(function(innerDone) {
innerDone();
innerDone();
});
});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalled();
const errors = reporter.jasmineDone.calls.argsFor(0)[0]
.failedExpectations;
expect(errors.length).toEqual(3);
expect(errors[0].message)
.withContext('error caused by beforeEach')
.toContain(message);
expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('error caused by it')
.toContain(message);
expect(errors[1].globalErrorType).toEqual('lateError');
expect(errors[2].message)
.withContext('error caused by afterEach')
.toContain(message);
expect(errors[2].globalErrorType).toEqual('lateError');
done();
});
});
it('reports multiple calls to done in reporters as errors', function(done) {
var message =
"An asynchronous reporter callback called its 'done' callback more " +
'than once.';
var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone']);
reporter.specDone = function(result, done) {
done();
done();
};
env.addReporter(reporter);
env.it('a spec', function() {});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalled();
const errors = reporter.jasmineDone.calls.argsFor(0)[0]
.failedExpectations;
expect(errors.length).toEqual(1);
expect(errors[0].message).toContain(message);
expect(errors[0].globalErrorType).toEqual('lateError');
done();
});
});
it('does not report an error for a call to done that comes after a timeout', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']),
firstSpecDone;
reporter.specDone = function(result, reporterDone) {
setTimeout(function() {
firstSpecDone();
reporterDone();
});
};
env.addReporter(reporter);
env.it(
'a spec',
function(innerDone) {
firstSpecDone = innerDone;
},
1
);
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
failedExpectations: []
})
);
done();
});
});
describe('suiteDone reporting', function() {
it('reports when an afterAll fails an expectation', function(done) {
var reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
@@ -656,8 +823,8 @@ describe('Env integration', function() {
});
env.execute(null, function() {
// Expect >= 9 rather than >= 10 to compensate for clock imprecision
expect(duration).toBeGreaterThanOrEqual(9);
// Expect > 0 to compensate for clock imprecision
expect(duration).toBeGreaterThan(0);
done();
});
});
@@ -683,8 +850,8 @@ describe('Env integration', function() {
});
env.execute(null, function() {
// Expect >= 9 rather than >= 10 to compensate for clock imprecision
expect(duration).toBeGreaterThanOrEqual(9);
// Expect > 0 to compensate for clock imprecision
expect(duration).toBeGreaterThan(0);
done();
});
});
@@ -1007,10 +1174,14 @@ describe('Env integration', function() {
});
it('Mock clock can be installed and used in tests', function(done) {
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
var globalSetTimeout = jasmine
.createSpy('globalSetTimeout')
.and.callFake(function(cb, t) {
setTimeout(cb, t);
return setTimeout(cb, t);
}),
delayedFunctionForGlobalClock = jasmine.createSpy(
'delayedFunctionForGlobalClock'
@@ -1025,7 +1196,7 @@ describe('Env integration', function() {
setTimeout: globalSetTimeout,
clearTimeout: clearTimeout,
setImmediate: function(cb) {
setTimeout(cb, 0);
return setTimeout(cb, 0);
}
}
});
@@ -1100,7 +1271,7 @@ describe('Env integration', function() {
setInterval: setInterval,
clearInterval: clearInterval,
setImmediate: function(cb) {
realSetTimeout(cb, 0);
return realSetTimeout(cb, 0);
}
}
});
@@ -1147,6 +1318,10 @@ describe('Env integration', function() {
});
it('should not use the mock clock for asynchronous timeouts', function(done) {
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
createMockedEnv();
var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']),
clock = env.clock;
@@ -1185,6 +1360,10 @@ describe('Env integration', function() {
});
it('should wait a custom interval before reporting async functions that fail to complete', function(done) {
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
createMockedEnv();
var reporter = jasmine.createSpyObj('fakeReport', [
'jasmineDone',
@@ -1948,6 +2127,7 @@ describe('Env integration', function() {
} catch (e) {
exception = e;
}
env.it('has a test', function() {});
});
env.execute(null, function() {
@@ -1972,6 +2152,7 @@ describe('Env integration', function() {
} catch (e) {
exception = e;
}
env.it('has a test', function() {});
});
env.execute(null, function() {
@@ -1994,6 +2175,7 @@ describe('Env integration', function() {
} catch (e) {
exception = e;
}
env.it('has a test', function() {});
});
env.execute(null, function() {
@@ -2033,6 +2215,7 @@ describe('Env integration', function() {
} catch (e) {
exception = e;
}
env.it('has a test', function() {});
});
env.execute(null, function() {
@@ -2239,7 +2422,7 @@ describe('Env integration', function() {
it('reports errors that occur during loading', function(done) {
var global = {
setTimeout: function(fn, delay) {
setTimeout(fn, delay);
return setTimeout(fn, delay);
},
clearTimeout: function(fn, delay) {
clearTimeout(fn, delay);
@@ -2296,7 +2479,7 @@ describe('Env integration', function() {
var originalOnerror = jasmine.createSpy('original onerror');
var global = {
setTimeout: function(fn, delay) {
setTimeout(fn, delay);
return setTimeout(fn, delay);
},
clearTimeout: function(fn, delay) {
clearTimeout(fn, delay);
@@ -2497,10 +2680,10 @@ describe('Env integration', function() {
it('is "failed"', function(done) {
var global = {
setTimeout: function(fn, delay) {
setTimeout(fn, delay);
return setTimeout(fn, delay);
},
clearTimeout: function(fn, delay) {
clearTimeout(fn, delay);
return clearTimeout(fn, delay);
}
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
@@ -2607,70 +2790,6 @@ describe('Env integration', function() {
});
});
it('should report deprecation warnings on the correct specs and suites', function(done) {
var reporter = jasmine.createSpyObj('reporter', [
'jasmineDone',
'suiteDone',
'specDone'
]);
// prevent deprecation from being displayed, as well as letting us observe calls
spyOn(console, 'error');
env.addReporter(reporter);
env.deprecated('top level deprecation');
env.describe('suite', function() {
env.beforeAll(function() {
env.deprecated('suite level deprecation');
});
env.it('spec', function() {
env.deprecated('spec level deprecation');
});
});
env.execute(null, function() {
var result = reporter.jasmineDone.calls.argsFor(0)[0];
expect(result.deprecationWarnings).toEqual([
jasmine.objectContaining({ message: 'top level deprecation' })
]);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: top level deprecation'
);
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'suite',
deprecationWarnings: [
jasmine.objectContaining({ message: 'suite level deprecation' })
]
})
);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: suite level deprecation (in suite: suite)'
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'suite spec',
deprecationWarnings: [
jasmine.objectContaining({ message: 'spec level deprecation' })
]
})
);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: spec level deprecation (in spec: suite spec)'
);
done();
});
});
it('should report deprecation stack with an error object', function(done) {
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
reporter = jasmine.createSpyObj('reporter', [
@@ -2720,7 +2839,7 @@ describe('Env integration', function() {
expect(result.deprecationWarnings).toEqual([
jasmine.objectContaining({
message: topLevelError.message,
stack: exceptionFormatter.stack(topLevelError)
stack: exceptionFormatter.stack(topLevelError, { omitMessage: true })
})
]);
@@ -2730,7 +2849,9 @@ describe('Env integration', function() {
deprecationWarnings: [
jasmine.objectContaining({
message: suiteLevelError.message,
stack: exceptionFormatter.stack(suiteLevelError)
stack: exceptionFormatter.stack(suiteLevelError, {
omitMessage: true
})
})
]
})
@@ -2742,7 +2863,9 @@ describe('Env integration', function() {
deprecationWarnings: [
jasmine.objectContaining({
message: specLevelError.message,
stack: exceptionFormatter.stack(specLevelError)
stack: exceptionFormatter.stack(specLevelError, {
omitMessage: true
})
})
]
})
@@ -2753,8 +2876,6 @@ describe('Env integration', function() {
});
it('supports async matchers', function(done) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'),
suiteDone = jasmine.createSpy('suiteDone'),
jasmineDone = jasmine.createSpy('jasmineDone');
@@ -2767,7 +2888,6 @@ describe('Env integration', function() {
function fail(innerDone) {
var resolve;
// eslint-disable-next-line compat/compat
var p = new Promise(function(res, rej) {
resolve = res;
});
@@ -2819,7 +2939,9 @@ describe('Env integration', function() {
});
it('provides custom equality testers to async matchers', function(done) {
jasmine.getEnv().requirePromises();
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
var specDone = jasmine.createSpy('specDone');
@@ -2829,7 +2951,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() {
return true;
});
var p = Promise.resolve('something'); // eslint-disable-line compat/compat
var p = Promise.resolve('something');
return env.expectAsync(p).toBeResolvedTo('something else');
});
@@ -2845,8 +2967,6 @@ describe('Env integration', function() {
});
it('includes useful stack frames in async matcher failures', function(done) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone');
env.addReporter({ specDone: specDone });
@@ -2855,7 +2975,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() {
return true;
});
var p = Promise.resolve(); // eslint-disable-line compat/compat
var p = Promise.resolve();
return env.expectAsync(p).toBeRejected();
});
@@ -2874,15 +2994,14 @@ describe('Env integration', function() {
});
it('reports an error when an async expectation occurs after the spec finishes', function(done) {
jasmine.getEnv().requirePromises();
var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(res) {
resolve = res;
});
env.configure({ random: false });
env.describe('a suite', function() {
env.it('does not wait', function() {
// Note: we intentionally don't return the result of each expectAsync.
@@ -2892,6 +3011,12 @@ describe('Env integration', function() {
});
});
env.it('another spec', function(done) {
// This is here to make sure that the async expectation evaluates
// before the Jasmine under test finishes, especially on Safari 8 and 9.
setTimeout(done, 10);
});
env.addReporter({
specDone: function() {
resolve();
@@ -2908,7 +3033,9 @@ describe('Env integration', function() {
message:
'Spec "a suite does not wait" ran a "toBeResolved" expectation ' +
'after it finished.\n' +
'Did you forget to return or await the result of expectAsync?',
'1. Did you forget to return or await the result of expectAsync?\n' +
'2. Was done() invoked before an async operation completed?\n' +
'3. Did an expectation follow a call to done()?',
matcherName: 'toBeResolved'
}),
jasmine.objectContaining({
@@ -2919,7 +3046,9 @@ describe('Env integration', function() {
'after it finished.\n' +
"Message: \"Expected a promise to be resolved to 'something else' " +
'but it was resolved to undefined."\n' +
'Did you forget to return or await the result of expectAsync?',
'1. Did you forget to return or await the result of expectAsync?\n' +
'2. Was done() invoked before an async operation completed?\n' +
'3. Did an expectation follow a call to done()?',
matcherName: 'toBeResolvedTo'
})
]);
@@ -2929,15 +3058,14 @@ describe('Env integration', function() {
});
it('reports an error when an async expectation occurs after the suite finishes', function(done) {
jasmine.getEnv().requirePromises();
var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(res) {
resolve = res;
});
env.configure({ random: false });
env.describe('a suite', function() {
env.afterAll(function() {
// Note: we intentionally don't return the result of expectAsync.
@@ -2948,6 +3076,12 @@ describe('Env integration', function() {
env.it('is a spec', function() {});
});
env.it('another spec', function(done) {
// This is here to make sure that the async expectation evaluates
// before the Jasmine under test finishes, especially on Safari 8 and 9.
setTimeout(done, 10);
});
env.addReporter({
suiteDone: function() {
resolve();
@@ -2964,7 +3098,9 @@ describe('Env integration', function() {
message:
'Suite "a suite" ran a "toBeResolved" expectation ' +
'after it finished.\n' +
'Did you forget to return or await the result of expectAsync?',
'1. Did you forget to return or await the result of expectAsync?\n' +
'2. Was done() invoked before an async operation completed?\n' +
'3. Did an expectation follow a call to done()?',
matcherName: 'toBeResolved'
})
]);
@@ -3002,6 +3138,115 @@ describe('Env integration', function() {
env.execute(null, done);
});
describe('The promise returned by #execute', function() {
beforeEach(function() {
this.savedInterval = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
});
afterEach(function() {
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.savedInterval;
});
it('is resolved after reporter events are dispatched', function() {
var reporter = jasmine.createSpyObj('reporter', [
'specDone',
'suiteDone',
'jasmineDone'
]);
env.addReporter(reporter);
env.describe('suite', function() {
env.it('spec', function() {});
});
return env.execute(null).then(function() {
expect(reporter.specDone).toHaveBeenCalled();
expect(reporter.suiteDone).toHaveBeenCalled();
expect(reporter.jasmineDone).toHaveBeenCalled();
});
});
it('is resolved after the stack is cleared', function(done) {
var realClearStack = jasmineUnderTest.getClearStack(
jasmineUnderTest.getGlobal()
),
clearStackSpy = jasmine
.createSpy('clearStack')
.and.callFake(realClearStack);
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
// Create a new env that has the clearStack defined above
env.cleanup_();
env = new jasmineUnderTest.Env();
env.describe('suite', function() {
env.it('spec', function() {});
});
env.execute(null).then(function() {
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
clearStackSpy.calls.reset();
setTimeout(function() {
expect(clearStackSpy).not.toHaveBeenCalled();
done();
});
});
});
it('is resolved after QueueRunner timeouts are cleared', function() {
var setTimeoutSpy = spyOn(
jasmineUnderTest.getGlobal(),
'setTimeout'
).and.callThrough();
var clearTimeoutSpy = spyOn(
jasmineUnderTest.getGlobal(),
'clearTimeout'
).and.callThrough();
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value
env = new jasmineUnderTest.Env();
env.describe('suite', function() {
env.it('spec', function() {});
});
return env.execute(null).then(function() {
var timeoutIds = setTimeoutSpy.calls
.all()
.filter(function(call) {
return call.args[1] === 123456;
})
.map(function(call) {
return call.returnValue;
});
expect(timeoutIds.length).toBeGreaterThan(0);
timeoutIds.forEach(function(timeoutId) {
expect(clearTimeoutSpy).toHaveBeenCalledWith(timeoutId);
});
});
});
it('is resolved to the value of the jasmineDone event', async function() {
env.describe('suite', function() {
env.it('spec', function() {
env.expect(true).toBe(false);
});
});
let event;
env.addReporter({
jasmineDone: e => (event = e)
});
const result = await env.execute();
expect(event.overallStatus).toEqual('failed');
expect(result).toEqual(event);
});
});
describe('The optional callback argument to #execute', function() {
beforeEach(function() {
this.savedInterval = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
@@ -3096,4 +3341,139 @@ describe('Env integration', function() {
});
});
});
it('sends debug logs to the reporter when the spec fails', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']),
startTime,
endTime;
env.addReporter(reporter);
env.configure({ random: false });
env.it('fails', function() {
startTime = new Date().getTime();
env.debugLog('message 1');
env.debugLog('message 2');
env.expect(1).toBe(2);
endTime = new Date().getTime();
});
env.it('passes', function() {
env.debugLog('message that should not be reported');
});
env.execute(null, function() {
function numberInRange(min, max) {
return {
asymmetricMatch: function(compareTo) {
return compareTo >= min && compareTo <= max;
},
jasmineToString: function(pp) {
return '<number from ' + min + ' to ' + max + ' inclusive>';
}
};
}
var duration;
expect(reporter.specDone).toHaveBeenCalledTimes(2);
duration = reporter.specDone.calls.argsFor(0)[0].duration;
expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(
jasmine.objectContaining({
debugLogs: [
{
timestamp: numberInRange(0, duration),
message: 'message 1'
},
{
timestamp: numberInRange(0, duration),
message: 'message 2'
}
]
})
);
expect(reporter.specDone.calls.argsFor(1)[0].debugLogs).toBeFalsy();
done();
});
});
it('reports an error when debugLog is used when a spec is not running', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['suiteDone']);
env.describe('a suite', function() {
env.beforeAll(function() {
env.debugLog('a message');
});
env.it('a spec', function() {});
});
env.addReporter(reporter);
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
failedExpectations: [
jasmine.objectContaining({
message: jasmine.stringContaining(
"'debugLog' was called when there was no current spec"
)
})
]
})
);
done();
});
});
it('uses custom equality testers in Spy#withArgs', async function() {
env.it('a spec', function() {
const createSpySpy = env.createSpy('via createSpy');
const spiedOn = { foo: function() {} };
env.spyOn(spiedOn, 'foo');
const spyObj = env.createSpyObj('spyObj', ['foo']);
const spiedOnAllFuncs = { foo: function() {} };
env.spyOnAllFunctions(spiedOnAllFuncs);
for (const spy of [
createSpySpy,
spiedOn.foo,
spyObj.foo,
spiedOnAllFuncs.foo
]) {
spy.and.returnValue('default strategy');
spy.withArgs(42).and.returnValue('custom strategy');
}
env.addCustomEqualityTester(function(a, b) {
if ((a === 'x' && b === 42) || (a === 42 && b === 'x')) {
return true;
}
});
env
.expect(createSpySpy('x'))
.withContext('createSpy')
.toEqual('custom strategy');
env
.expect(spiedOn.foo('x'))
.withContext('spyOn')
.toEqual('custom strategy');
env
.expect(spyObj.foo('x'))
.withContext('createSpyObj')
.toEqual('custom strategy');
env
.expect(spiedOnAllFuncs.foo('x'))
.withContext('spyOnAllFunctions')
.toEqual('custom strategy');
});
let failedExpectations;
env.addReporter({
specDone: r => (failedExpectations = r.failedExpectations)
});
await env.execute();
expect(failedExpectations).toEqual([]);
});
});

View File

@@ -90,8 +90,6 @@ describe('Matchers (Integration)', function() {
function verifyPassesAsync(expectations) {
it('passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return expectations(env);
});
@@ -118,8 +116,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsAsync(expectations) {
it('fails', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return expectations(env);
});
@@ -147,7 +143,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsWithCustomObjectFormattersAsync(config) {
it('uses custom object formatters', function(done) {
var env = new jasmineUnderTest.Env();
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
env.addCustomObjectFormatter(config.formatter);
return config.expectations(env);
@@ -348,12 +343,10 @@ describe('Matchers (Integration)', function() {
describe('toBeResolved', function() {
verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeResolved();
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject()).toBeResolved();
});
});
@@ -363,12 +356,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar');
});
@@ -377,7 +368,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y');
},
expectedMessage:
@@ -388,12 +378,10 @@ describe('Matchers (Integration)', function() {
describe('toBeRejected', function() {
verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('nope')).toBeRejected();
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejected();
});
});
@@ -403,12 +391,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope');
});
@@ -417,7 +403,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y');
},
expectedMessage:
@@ -428,16 +413,12 @@ describe('Matchers (Integration)', function() {
describe('toBeRejectedWithError', function() {
verifyPassesAsync(function(env) {
return (
env
// eslint-disable-next-line compat/compat
.expectAsync(Promise.reject(new Error()))
.toBeRejectedWithError(Error)
);
return env
.expectAsync(Promise.reject(new Error()))
.toBeRejectedWithError(Error);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error);
});
@@ -446,12 +427,9 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
return (
env
// eslint-disable-next-line compat/compat
.expectAsync(Promise.reject('foo'))
.toBeRejectedWithError('foo')
);
return env
.expectAsync(Promise.reject('foo'))
.toBeRejectedWithError('foo');
},
expectedMessage:
'Expected a promise to be rejected with Error: |foo| ' +
@@ -754,4 +732,78 @@ describe('Matchers (Integration)', function() {
'a predicate, but it threw Error with message |nope|.'
});
});
describe('When an async matcher is used with .already()', function() {
it('propagates the matcher result when the promise is resolved', function(done) {
env.it('a spec', function() {
return env.expectAsync(Promise.resolve()).already.toBeRejected();
});
var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message).toEqual(
'Expected [object Promise] to be rejected.'
);
expect(result.failedExpectations[0].matcherName)
.withContext('Matcher name')
.not.toEqual('');
};
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('propagates the matcher result when the promise is rejected', function(done) {
env.it('a spec', function() {
return env
.expectAsync(Promise.reject(new Error('nope')))
.already.toBeResolved();
});
var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message).toEqual(
'Expected a promise to be resolved but it was ' +
'rejected with Error: nope.'
);
expect(result.failedExpectations[0].matcherName)
.withContext('Matcher name')
.not.toEqual('');
};
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('fails when the promise is pending', function(done) {
var promise = new Promise(function() {});
env.it('a spec', function() {
return env.expectAsync(promise).already.toBeResolved();
});
var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message).toEqual(
'Expected a promise to be settled ' +
'(via expectAsync(...).already) but it was pending.'
);
expect(result.failedExpectations[0].matcherName)
.withContext('Matcher name')
.not.toEqual('');
};
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
});
});

View File

@@ -550,10 +550,17 @@ describe('spec running', function() {
var pendingSpec,
suite = env.describe('default current suite', function() {
pendingSpec = env.it('I am a pending spec');
});
}),
reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
env.execute(null, function() {
expect(pendingSpec.status()).toBe('pending');
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
status: 'pending'
})
);
done();
});
});
@@ -785,9 +792,9 @@ describe('spec running', function() {
});
});
describe('When throwOnExpectationFailure is set', function() {
it('skips to cleanup functions after an error', function(done) {
var actions = [];
function hasStandardErrorHandlingBehavior() {
it('skips to cleanup functions after a thrown error', async function() {
const actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
@@ -814,79 +821,18 @@ describe('spec running', function() {
});
});
env.configure({ oneFailurePerSpec: true });
await env.execute();
env.execute(null, function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
'outer afterEach'
]);
done();
});
expect(actions).toEqual(['outer beforeEach', 'outer afterEach']);
});
it('skips to cleanup functions after done.fail is called', function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function(done) {
actions.push('beforeEach');
done.fail('error');
actions.push('after done.fail');
});
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it', function() {
actions.push('it');
});
});
env.configure({ oneFailurePerSpec: true });
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
done();
});
});
it('skips to cleanup functions when an async function times out', function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function(innerDone) {
actions.push('beforeEach');
}, 1);
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it', function() {
actions.push('it');
});
});
env.configure({ oneFailurePerSpec: true });
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
done();
});
});
it('skips to cleanup functions after an error with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
it('skips to cleanup functions after a rejected promise', async function() {
const actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
throw new Error('error');
return Promise.reject(new Error('error'));
});
env.afterEach(function() {
@@ -908,29 +854,18 @@ describe('spec running', function() {
});
});
env.throwOnExpectationFailure(true);
await env.execute();
env.execute(null, function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
'outer afterEach'
]);
expect(env.deprecated).toHaveBeenCalled();
done();
});
expect(actions).toEqual(['outer beforeEach', 'outer afterEach']);
});
it('skips to cleanup functions after done.fail is called with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
it('skips to cleanup functions after done.fail is called', async function() {
const actions = [];
env.describe('Something', function() {
env.beforeEach(function(done) {
actions.push('beforeEach');
done.fail('error');
actions.push('after done.fail');
});
env.afterEach(function() {
@@ -942,19 +877,13 @@ describe('spec running', function() {
});
});
env.throwOnExpectationFailure(true);
await env.execute();
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
expect(env.deprecated).toHaveBeenCalled();
done();
});
expect(actions).toEqual(['beforeEach', 'afterEach']);
});
it('skips to cleanup functions when an async function times out with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
it('skips to cleanup functions when an async function times out', async function() {
const actions = [];
env.describe('Something', function() {
env.beforeEach(function(innerDone) {
@@ -970,45 +899,408 @@ describe('spec running', function() {
});
});
env.throwOnExpectationFailure(true);
await env.execute();
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
expect(env.deprecated).toHaveBeenCalled();
done();
expect(actions).toEqual(['beforeEach', 'afterEach']);
});
it('skips to cleanup functions after pending() is called', async function() {
const actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
pending();
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.describe('Inner', function() {
env.beforeEach(function() {
actions.push('inner beforeEach');
});
env.afterEach(function() {
actions.push('inner afterEach');
});
env.it('does it', function() {
actions.push('inner it');
});
});
});
await env.execute();
expect(actions).toEqual(['outer beforeEach', 'outer afterEach']);
});
it('runs all reporter callbacks even if one fails', async function() {
const laterReporter = jasmine.createSpyObj('laterReporter', ['specDone']);
env.it('a spec', function() {});
env.addReporter({
specDone: function() {
throw new Error('nope');
}
});
env.addReporter(laterReporter);
await env.execute();
expect(laterReporter.specDone).toHaveBeenCalled();
});
it('skips cleanup functions that are defined in child suites when a beforeEach errors', async function() {
const parentAfterEachFn = jasmine.createSpy('parentAfterEachFn');
const childAfterEachFn = jasmine.createSpy('childAfterEachFn');
env.describe('parent suite', function() {
env.beforeEach(function() {
throw new Error('nope');
});
env.afterEach(parentAfterEachFn);
env.describe('child suite', function() {
env.it('a spec', function() {});
env.afterEach(childAfterEachFn);
});
});
await env.execute();
expect(parentAfterEachFn).toHaveBeenCalled();
expect(childAfterEachFn).not.toHaveBeenCalled();
});
}
describe('When stopSpecOnExpectationFailure is true', function() {
beforeEach(function() {
env.configure({ stopSpecOnExpectationFailure: true });
});
hasStandardErrorHandlingBehavior();
it('skips to cleanup functions after an expectation failure', async function() {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
env.expect(1).toBe(2);
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.describe('Inner', function() {
env.beforeEach(function() {
actions.push('inner beforeEach');
});
env.afterEach(function() {
actions.push('inner afterEach');
});
env.it('does it', function() {
actions.push('inner it');
});
});
});
await env.execute();
expect(actions).toEqual(['outer beforeEach', 'outer afterEach']);
});
});
describe('When stopSpecOnExpectationFailure is false', function() {
beforeEach(function() {
env.configure({ stopSpecOnExpectationFailure: false });
});
hasStandardErrorHandlingBehavior();
it('does not skip anything after an expectation failure', async function() {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
env.expect(1).toBe(2);
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.describe('Inner', function() {
env.beforeEach(function() {
actions.push('inner beforeEach');
});
env.afterEach(function() {
actions.push('inner afterEach');
});
env.it('does it', function() {
actions.push('inner it');
});
});
});
await env.execute();
expect(actions).toEqual([
'outer beforeEach',
'inner beforeEach',
'inner it',
'inner afterEach',
'outer afterEach'
]);
});
});
describe('When a top-level beforeAll function fails', function() {
it('skips and reports contained specs', async function() {
const outerBeforeEach = jasmine.createSpy('outerBeforeEach');
const nestedBeforeEach = jasmine.createSpy('nestedBeforeEach');
const outerAfterEach = jasmine.createSpy('outerAfterEach');
const nestedAfterEach = jasmine.createSpy('nestedAfterEach');
const outerIt = jasmine.createSpy('outerIt');
const nestedIt = jasmine.createSpy('nestedIt');
const nestedBeforeAll = jasmine.createSpy('nestedBeforeAll');
env.beforeAll(function() {
throw new Error('nope');
});
env.beforeEach(outerBeforeEach);
env.it('a spec', outerIt);
env.describe('a nested suite', function() {
env.beforeAll(nestedBeforeAll);
env.beforeEach(nestedBeforeEach);
env.it('a nested spec', nestedIt);
env.afterEach(nestedAfterEach);
});
env.afterEach(outerAfterEach);
const reporter = jasmine.createSpyObj('reporter', [
'suiteStarted',
'suiteDone',
'specStarted',
'specDone'
]);
env.addReporter(reporter);
await env.execute();
expect(outerBeforeEach).not.toHaveBeenCalled();
expect(outerIt).not.toHaveBeenCalled();
expect(nestedBeforeAll).not.toHaveBeenCalled();
expect(nestedBeforeEach).not.toHaveBeenCalled();
expect(nestedIt).not.toHaveBeenCalled();
expect(nestedAfterEach).not.toHaveBeenCalled();
expect(outerAfterEach).not.toHaveBeenCalled();
expect(reporter.suiteStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a nested suite'
})
);
// The child suite should be reported as passed, for consistency with
// suites that contain failing specs but no suite-level errors.
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a nested suite',
status: 'passed',
failedExpectations: []
})
);
expect(reporter.specStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a spec'
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a spec',
status: 'failed',
failedExpectations: [
jasmine.objectContaining({
passed: false,
message:
'Not run because a beforeAll function failed. The ' +
'beforeAll failure will be reported on the suite that ' +
'caused it.'
})
]
})
);
expect(reporter.specStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a nested suite a nested spec'
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a nested suite a nested spec',
status: 'failed',
failedExpectations: [
jasmine.objectContaining({
passed: false,
message:
'Not run because a beforeAll function failed. The ' +
'beforeAll failure will be reported on the suite that ' +
'caused it.'
})
]
})
);
});
});
describe('When a suite beforeAll function fails', function() {
it('skips and reports contained specs', async function() {
const outerBeforeEach = jasmine.createSpy('outerBeforeEach');
const nestedBeforeEach = jasmine.createSpy('nestedBeforeEach');
const outerAfterEach = jasmine.createSpy('outerAfterEach');
const nestedAfterEach = jasmine.createSpy('nestedAfterEach');
const outerIt = jasmine.createSpy('outerIt');
const nestedIt = jasmine.createSpy('nestedIt');
const nestedBeforeAll = jasmine.createSpy('nestedBeforeAll');
env.describe('a suite', function() {
env.beforeAll(function() {
throw new Error('nope');
});
env.beforeEach(outerBeforeEach);
env.it('a spec', outerIt);
env.describe('a nested suite', function() {
env.beforeAll(nestedBeforeAll);
env.beforeEach(nestedBeforeEach);
env.it('a nested spec', nestedIt);
env.afterEach(nestedAfterEach);
});
env.afterEach(outerAfterEach);
});
const reporter = jasmine.createSpyObj('reporter', [
'suiteStarted',
'suiteDone',
'specStarted',
'specDone'
]);
env.addReporter(reporter);
await env.execute();
expect(outerBeforeEach).not.toHaveBeenCalled();
expect(outerIt).not.toHaveBeenCalled();
expect(nestedBeforeAll).not.toHaveBeenCalled();
expect(nestedBeforeEach).not.toHaveBeenCalled();
expect(nestedIt).not.toHaveBeenCalled();
expect(nestedAfterEach).not.toHaveBeenCalled();
expect(outerAfterEach).not.toHaveBeenCalled();
expect(reporter.suiteStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a nested suite'
})
);
// The child suite should be reported as passed, for consistency with
// suites that contain failing specs but no suite-level errors.
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a nested suite',
status: 'passed',
failedExpectations: []
})
);
expect(reporter.specStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a spec'
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a spec',
status: 'failed',
failedExpectations: [
jasmine.objectContaining({
passed: false,
message:
'Not run because a beforeAll function failed. The ' +
'beforeAll failure will be reported on the suite that ' +
'caused it.'
})
]
})
);
expect(reporter.specStarted).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a nested suite a nested spec'
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'a suite a nested suite a nested spec',
status: 'failed',
failedExpectations: [
jasmine.objectContaining({
passed: false,
message:
'Not run because a beforeAll function failed. The ' +
'beforeAll failure will be reported on the suite that ' +
'caused it.'
})
]
})
);
});
it('runs afterAll functions in the current suite and outer scopes', async function() {
const outerAfterAll = jasmine.createSpy('outerAfterAll');
const nestedAfterAll = jasmine.createSpy('nestedAfterAll');
const secondNestedAfterAll = jasmine.createSpy('secondNestedAfterAll');
env.describe('a nested suite', function() {
env.beforeAll(function() {
throw new Error('nope');
});
env.describe('more nesting', function() {
env.it('a nested spec', function() {});
env.afterAll(secondNestedAfterAll);
});
env.afterAll(nestedAfterAll);
});
env.afterAll(outerAfterAll);
await env.execute();
expect(secondNestedAfterAll).not.toHaveBeenCalled();
expect(nestedAfterAll).toHaveBeenCalled();
expect(outerAfterAll).toHaveBeenCalled();
});
});
describe('when stopOnSpecFailure is on', function() {
it('does not run further specs when one fails', function(done) {
var actions = [];
env.describe('wrapper', function() {
env.it('fails', function() {
actions.push('fails');
env.expect(1).toBe(2);
});
});
env.describe('holder', function() {
env.it('does not run', function() {
actions.push('does not run');
});
});
env.configure({ random: false, failFast: true });
env.execute(null, function() {
expect(actions).toEqual(['fails']);
done();
});
});
it('does not run further specs when one fails when configured with deprecated option', function(done) {
var actions = [];
spyOn(env, 'deprecated');
var actions = [],
config;
env.describe('wrapper', function() {
env.it('fails', function() {
@@ -1024,13 +1316,254 @@ describe('spec running', function() {
});
env.configure({ random: false });
env.stopOnSpecFailure(true);
env.configure({ stopOnSpecFailure: true });
env.execute(null, function() {
expect(actions).toEqual(['fails']);
expect(env.deprecated).toHaveBeenCalled();
done();
});
});
it('runs afterAll functions', async function() {
const actions = [];
env.describe('outer suite', function() {
env.describe('inner suite', function() {
env.it('fails', function() {
actions.push('fails');
env.expect(1).toBe(2);
});
env.afterAll(function() {
actions.push('inner afterAll');
});
});
env.afterAll(function() {
actions.push('outer afterAll');
});
});
env.afterAll(function() {
actions.push('top afterAll');
});
env.configure({ stopOnSpecFailure: true });
await env.execute();
expect(actions).toEqual([
'fails',
'inner afterAll',
'outer afterAll',
'top afterAll'
]);
});
});
describe('run multiple times', function() {
beforeEach(function() {
env.configure({ autoCleanClosures: false, random: false });
});
it('should be able to run multiple times', function(done) {
var actions = [];
env.describe('Suite', function() {
env.it('spec1', function() {
actions.push('spec1');
});
env.describe('inner suite', function() {
env.it('spec2', function() {
actions.push('spec2');
});
});
});
env.execute(null, function() {
expect(actions).toEqual(['spec1', 'spec2']);
env.execute(null, function() {
expect(actions).toEqual(['spec1', 'spec2', 'spec1', 'spec2']);
done();
});
});
});
it('should reset results between runs', function(done) {
var specResults = {};
var suiteResults = {};
var firstExecution = true;
env.addReporter({
specDone: function(spec) {
specResults[spec.description] = spec.status;
},
suiteDone: function(suite) {
suiteResults[suite.description] = suite.status;
},
jasmineDone: function() {
firstExecution = false;
}
});
env.describe('suite0', function() {
env.it('spec1', function() {
if (firstExecution) {
env.expect(1).toBe(2);
}
});
env.describe('suite1', function() {
env.it('spec2', function() {
if (firstExecution) {
env.pending();
}
});
env.xit('spec3', function() {}); // Always pending
});
env.describe('suite2', function() {
env.it('spec4', function() {
if (firstExecution) {
throw new Error('spec 3 fails');
}
});
});
env.describe('suite3', function() {
env.beforeEach(function() {
throw new Error('suite 3 fails');
});
env.it('spec5', function() {});
});
env.xdescribe('suite4', function() {
// Always pending
env.it('spec6', function() {});
});
env.describe('suite5', function() {
env.it('spec7');
});
});
env.execute(null, function() {
expect(specResults).toEqual({
spec1: 'failed',
spec2: 'pending',
spec3: 'pending',
spec4: 'failed',
spec5: 'failed',
spec6: 'pending',
spec7: 'pending'
});
expect(suiteResults).toEqual({
suite0: 'passed',
suite1: 'passed',
suite2: 'passed',
suite3: 'passed',
suite4: 'pending',
suite5: 'passed'
});
env.execute(null, function() {
expect(specResults).toEqual({
spec1: 'passed',
spec2: 'passed',
spec3: 'pending',
spec4: 'passed',
spec5: 'failed',
spec6: 'pending',
spec7: 'pending'
});
expect(suiteResults).toEqual({
suite0: 'passed',
suite1: 'passed',
suite2: 'passed',
suite3: 'passed',
suite4: 'pending',
suite5: 'passed'
});
done();
});
});
});
it('should execute before and after hooks per run', function(done) {
var timeline = [];
var timelineFn = function(hookName) {
return function() {
timeline.push(hookName);
};
};
var expectedTimeLine = [
'beforeAll',
'beforeEach',
'spec1',
'afterEach',
'beforeEach',
'spec2',
'afterEach',
'afterAll'
];
env.describe('suite0', function() {
env.beforeAll(timelineFn('beforeAll'));
env.beforeEach(timelineFn('beforeEach'));
env.afterEach(timelineFn('afterEach'));
env.afterAll(timelineFn('afterAll'));
env.it('spec1', timelineFn('spec1'));
env.it('spec2', timelineFn('spec2'));
});
env.execute(null, function() {
expect(timeline).toEqual(expectedTimeLine);
timeline = [];
env.execute(null, function() {
expect(timeline).toEqual(expectedTimeLine);
done();
});
});
});
it('should be able to filter out different tests in subsequent runs', function(done) {
var specResults = {};
var focussedSpec = 'spec1';
env.configure({
specFilter: function(spec) {
return spec.description === focussedSpec;
}
});
env.addReporter({
specDone: function(spec) {
specResults[spec.description] = spec.status;
}
});
env.describe('suite0', function() {
env.it('spec1', function() {});
env.it('spec2', function() {});
env.it('spec3', function() {});
});
env.execute(null, function() {
expect(specResults).toEqual({
spec1: 'passed',
spec2: 'excluded',
spec3: 'excluded'
});
focussedSpec = 'spec2';
env.execute(null, function() {
expect(specResults).toEqual({
spec1: 'excluded',
spec2: 'passed',
spec3: 'excluded'
});
focussedSpec = 'spec3';
env.execute(null, function() {
expect(specResults).toEqual({
spec1: 'excluded',
spec2: 'excluded',
spec3: 'passed'
});
done();
});
});
});
});
});
});

View File

@@ -112,7 +112,7 @@ describe('DiffBuilder', function() {
return '[number:' + x + ']';
}
};
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
var diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
@@ -131,7 +131,7 @@ describe('DiffBuilder', function() {
return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']';
}
};
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
var diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBePending', function() {
it('passes if the actual promise is pending', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = new Promise(function() {});
@@ -13,8 +10,6 @@ describe('toBePending', function() {
});
it('fails if the actual promise is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.resolve();
@@ -25,8 +20,6 @@ describe('toBePending', function() {
});
it('fails if the actual promise is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.reject(new Error('promise was rejected'));

Some files were not shown because too many files have changed in this diff Show More