Compare commits

..

61 Commits

Author SHA1 Message Date
Steve Gravrock
00586e50e0 Bump version to 3.8.0 2021-07-01 17:06:14 -07: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
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
9065b4c3b7 Added a jsdoc cross-reference from Configuration to its usage 2021-05-21 17:13:07 -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
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
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
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
cb044aa273 Bump version to 3.7.1 2021-03-18 17:28:04 -07:00
Steve Gravrock
5c17456925 Updated release instructions 2021-03-17 19:44:16 -07:00
Daniel Kurka
2745d7d515 Add support for ArrayBuffers to matcherUtil.equals.
Fixes #1687
2019-05-02 09:49:21 -07:00
62 changed files with 2191 additions and 451 deletions

216
.circleci/config.yml Normal file
View File

@@ -0,0 +1,216 @@
# 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:
docker:
- image: circleci/node:12
working_directory: ~/workspace
node10:
docker:
- image: circleci/node:10
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
# Warning: Sometimes takes a very long time (>25 minutes) on Circle.
# Probably not a good idea to run it from anything but a nightly.
test_node_with_long_property_tests:
<<: *test_node
environment:
JASMINE_LONG_PROPERTY_TESTS: y
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 10 * * *"
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
name: build_node_12
- build:
executor: node10
name: build_node_10
- test_node:
executor: node16
name: test_node_16
requires:
- build_node_16
- test_node_with_long_property_tests:
executor: node14
requires:
- build_node_14
- test_node:
executor: node12
name: test_node_12
requires:
- build_node_12
- test_node:
executor: node10
name: test_node_10
requires:
- build_node_10
- 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
name: build_node_12
- build:
executor: node10
name: build_node_10
- 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
name: test_node_12
requires:
- build_node_12
- test_node:
executor: node10
name: test_node_10
requires:
- build_node_10
- 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 11 * * *"
filters:
branches:
only:
- main
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

@@ -1,6 +1,12 @@
# 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
@@ -35,8 +41,8 @@ Once you've pushed a feature branch to your forked repo, you're ready to open a
* `/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, Ruby, and Python packages.
### Self-testing
@@ -48,35 +54,23 @@ The tests should always use `jasmineUnderTest` to refer to the objects and funct
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.
### 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 browsers, including some older browsers that do
not support the latest JavaScript features. 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,22 +82,35 @@ 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_ - 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.
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. It's also a good idea to run the tests in Internet
Explorer if you've touched code in `src/html`, if your change involves newer
JavaScript language/runtime features, or if you're unfamiliar with writing code
for older 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, you can also use Jasmine's
CI tooling:
You can also set the `JASMINE_BROWSER` environment variable to specify which browser should be used.
$ JASMINE_BROWSER=<name of browser> node spec/support/ci.js
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.
@@ -112,16 +119,16 @@ The easiest way to run the tests in **Internet Explorer** is to run a VM that ha
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.
1. With `npm run serve` running on your host machine, navigate to `http://<your IP address>:8888` in IE.
## Before Committing or Submitting a Pull Request
1. Ensure all specs are green in browser *and* node
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. 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.
Note that we use Circle CI for Continuous Integration. We only accept green pull requests.

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)

1
.gitignore vendored
View File

@@ -25,3 +25,4 @@ build/
dist
nbproject/
*.iml
.envrc

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

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,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,8 +11,6 @@ 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).
## Contributing
Please read the [contributors' guide](https://github.com/jasmine/jasmine/blob/main/.github/CONTRIBUTING.md).
@@ -22,15 +20,12 @@ 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 browser runner:<br>
[https://github.com/jasmine/jasmine-browser](https://github.com/jasmine/jasmine-browser).
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).
To install Jasmine standalone on your local box (where **_{#.#.#}_** below is substituted by the release number downloaded):
* Download the standalone distribution for your desired release from the [releases page](https://github.com/jasmine/jasmine/releases).
@@ -56,10 +51,10 @@ Jasmine tests itself across many browsers (Safari, Chrome, Firefox, Microsoft Ed
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14 |
| Safari | 8-13 |
| Node | 10, 12, 14, 16 |
| Safari | 8-14 |
| Chrome | Evergreen |
| Firefox | Evergreen, 68 |
| Firefox | Evergreen, 68, 78 |
| Edge | Evergreen |
| Internet Explorer | 10, 11 |

View File

@@ -28,19 +28,22 @@ 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. Run the browser tests using `scripts/run-all-browsers`.
1. Commit release notes and version changes (jasmine.js, version.rb, 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
@@ -56,6 +59,7 @@ Install [twine](https://github.com/pypa/twine)
### 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`
@@ -75,9 +79,9 @@ 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. `grunt release `
1. `npm publish .`
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
@@ -85,7 +89,7 @@ Probably only need to do this when releasing a minor version, and not a patch ve
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. Wait for Circle CI to go green again.
1. `rake release`
### Finally

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,4 +1,33 @@
import pkg_resources
import os
if 'SUPPRESS_JASMINE_DEPRECATION' not in os.environ:
print('DEPRECATION WARNING:\n' +
'\n' +
'The Jasmine packages for Python are deprecated. There will be no further\n' +
'releases after the end of the Jasmine 3.x series. We recommend migrating to the\n' +
'following options:\n' +
'\n' +
'* jasmine-browser-runner (<https://github.com/jasmine/jasmine-browser>,\n' +
' `npm install jasmine-browser-runner`) to run specs in browsers, including\n' +
' headless Chrome and Saucelabs. This is the most direct replacement for the\n' +
' jasmine server` and `jasmine ci` commands provided by the `jasmine` Python\n' +
' package.\n' +
'* The jasmine npm package (<https://github.com/jasmine/jasmine-npm>,\n' +
' `npm install jasmine`) to run specs under Node.js.\n' +
'* The standalone distribution from the latest Jasmine release\n' +
' <https://github.com/jasmine/jasmine/releases> to run specs in browsers with\n' +
' no additional tools.\n' +
'* The jasmine-core npm package (`npm install jasmine-core`) if all you need is\n' +
' the Jasmine assets. This is the direct equivalent of the jasmine-core Python\n' +
' package.\n' +
'\n' +
'Except for the standalone distribution, all of the above are distributed through\n' +
'npm.\n' +
'\n' +
'To prevent this message from appearing, set the SUPPRESS_JASMINE_DEPRECATION\n' +
'environment variable.\n')
try:
from collections import OrderedDict

View File

@@ -208,7 +208,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',
@@ -565,7 +568,7 @@ jasmineRequire.HtmlReporter = function(j$) {
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.onclick = function() {
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
};
var randomCheckbox = optionsMenuDom.querySelector(
@@ -635,7 +638,11 @@ 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) {
@@ -699,11 +706,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

View File

@@ -371,6 +371,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return matches ? matches[1] : '<anonymous>';
};
j$.isPending_ = function(promise) {
var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) {
return result === sentinel;
},
function() {
return false;
}
);
};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is an instance of the specified class/constructor.
@@ -679,11 +692,21 @@ getJasmineRequireObj().util = function(j$) {
};
getJasmineRequireObj().Spec = function(j$) {
/**
* @interface Spec
* @see Configuration#specFilter
*/
function Spec(attrs) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id;
/**
* The description passed to the {@link it} that created this spec.
* @name Spec#description
* @readonly
* @type {string}
*/
this.description = attrs.description || '';
this.queueableFn = attrs.queueableFn;
this.beforeAndAfterFns =
@@ -875,6 +898,12 @@ getJasmineRequireObj().Spec = function(j$) {
return 'passed';
};
/**
* The full description including all ancestors of this spec.
* @name Spec#getFullName
* @function
* @returns {string}
*/
Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};
@@ -963,11 +992,12 @@ getJasmineRequireObj().Order = function() {
getJasmineRequireObj().Env = function(j$) {
/**
* _Note:_ Do not construct this directly, Jasmine will make one during booting.
* @name Env
* @class Env
* @since 2.0.0
* @classdesc The Jasmine environment
* @constructor
* @classdesc The Jasmine environment.<br>
* _Note:_ Do not construct this directly. You can obtain the Env instance by
* calling {@link jasmine.getEnv}.
* @hideconstructor
*/
function Env(options) {
options = options || {};
@@ -998,7 +1028,8 @@ getJasmineRequireObj().Env = function(j$) {
/**
* This represents the available options to configure Jasmine.
* Options that are not provided will use their default values
* Options that are not provided will use their default values.
* @see Env#configure
* @interface Configuration
* @since 3.3.0
*/
@@ -1016,7 +1047,7 @@ getJasmineRequireObj().Env = function(j$) {
* Null causes the seed to be determined randomly at the start of execution.
* @name Configuration#seed
* @since 3.3.0
* @type function
* @type (number|string)
* @default null
*/
seed: null,
@@ -1046,12 +1077,19 @@ getJasmineRequireObj().Env = function(j$) {
* @default false
*/
oneFailurePerSpec: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
* @callback SpecFilter
* @param {Spec} spec - The spec that the filter is being applied to.
* @return boolean
*/
/**
* Function to use to filter specs
* @name Configuration#specFilter
* @since 3.3.0
* @type function
* @default true
* @type SpecFilter
* @default A function that always returns true.
*/
specFilter: function() {
return true;
@@ -1602,6 +1640,13 @@ getJasmineRequireObj().Env = function(j$) {
defaultResourcesForRunnable(topSuite.id);
currentDeclarationSuite = topSuite;
/**
* Provides the root suite, through which all suites and specs can be
* accessed.
* @function
* @name Env#topSuite
* @return {Suite} the root suite
*/
this.topSuite = function() {
return topSuite;
};
@@ -1681,7 +1726,27 @@ getJasmineRequireObj().Env = function(j$) {
queueRunnerFactory
);
// Both params are optional.
/**
* Executes the specs.
*
* If called with no parameters or with a falsy value as the first parameter,
* all specs will be executed except those that are excluded by a
* [spec filter]{@link Configuration#specFilter} or other mechanism. If the
* first parameter is a list of spec/suite IDs, only those specs/suites will
* be run.
*
* Both parameters are optional, but a completion callback is only valid as
* the second parameter. To specify a completion callback but not a list of
* specs/suites to run, pass null or undefined as the first parameter.
*
* execute should not be called more than once.
*
* @name Env#execute
* @since 2.0.0
* @function
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
* @param {Function=} onComplete Function that will be called after all specs have run
*/
this.execute = function(runnablesToRun, onComplete) {
installGlobalErrors();
@@ -1873,6 +1938,15 @@ getJasmineRequireObj().Env = function(j$) {
}
});
/**
* Configures whether Jasmine should allow the same function to be spied on
* more than once during the execution of a spec. By default, spying on
* a function that is already a spy will cause an error.
* @name Env#allowRespy
* @function
* @since 2.5.0
* @param {boolean} allow Whether to allow respying
*/
this.allowRespy = function(allow) {
spyRegistry.allowRespy(allow);
};
@@ -2942,6 +3016,18 @@ getJasmineRequireObj().CallTracker = function(j$) {
return call ? call.args : [];
};
/**
* Get the "this" object that was passed to a specific invocation of this spy.
* @name Spy#calls#thisFor
* @function
* @param {Integer} index The 0-based invocation index.
* @return {Object?}
*/
this.thisFor = function(index) {
var call = calls[index];
return call ? call.object : undefined;
};
/**
* Get the raw calls array for this spy.
* @name Spy#calls#all
@@ -3093,9 +3179,11 @@ getJasmineRequireObj().Clock = function() {
typeof process.versions.node === 'string';
/**
* _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
* @class Clock
* @classdesc Jasmine's mock clock is used when testing time dependent code.
* @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
* _Note:_ Do not construct this directly. You can get the current clock with
* {@link jasmine.clock}.
* @hideconstructor
*/
function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
var self = this,
@@ -3651,7 +3739,35 @@ getJasmineRequireObj().Expectation = function(j$) {
});
/**
* Asynchronous matchers.
* Asynchronous matchers that operate on an actual value which is a promise,
* and return a promise.
*
* Most async matchers will wait indefinitely for the promise to be resolved
* or rejected, resulting in a spec timeout if that never happens. If you
* expect that the promise will already be resolved or rejected at the time
* the matcher is called, you can use the {@link async-matchers#already}
* modifier to get a faster failure with a more helpful message.
*
* Note: Specs must await the result of each async matcher, return the
* promise returned by the matcher, or return a promise that's derived from
* the one returned by the matcher. Otherwise the matcher will not be
* evaluated before the spec completes.
*
* @example
* // Good
* await expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved()
* .then(function() {
* // more spec code
* });
* @example
* // Bad
* expectAsync(aPromise).toBeResolved();
* @namespace async-matchers
*/
function AsyncExpectation(options) {
@@ -3701,6 +3817,23 @@ getJasmineRequireObj().Expectation = function(j$) {
}
});
/**
* Fail as soon as possible if the actual is pending.
* Otherwise evaluate the matcher.
* @member
* @name async-matchers#already
* @type {async-matchers}
* @example
* await expectAsync(myPromise).already.toBeResolved();
* @example
* return expectAsync(myPromise).already.toBeResolved();
*/
Object.defineProperty(AsyncExpectation.prototype, 'already', {
get: function() {
return addFilter(this, expectSettledPromiseFilter);
}
});
function wrapSyncCompare(name, matcherFactory) {
return function() {
var result = this.expector.compare(name, matcherFactory, arguments);
@@ -3779,6 +3912,27 @@ getJasmineRequireObj().Expectation = function(j$) {
buildFailureMessage: negatedFailureMessage
};
var expectSettledPromiseFilter = {
selectComparisonFunc: function(matcher) {
return function(actual) {
var matcherArgs = arguments;
return j$.isPending_(actual).then(function(isPending) {
if (isPending) {
return {
pass: false,
message:
'Expected a promise to be settled (via ' +
'expectAsync(...).already) but it was pending.'
};
} else {
return matcher.compare.apply(null, matcherArgs);
}
});
};
}
};
function ContextAddingFilter(message) {
this.message = message;
}
@@ -4074,7 +4228,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
this.jasmineHandlers = {};
this.installOne_ = function installOne_(errorType, jasmineMessage) {
function taggedOnError(error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
var substituteMsg;
if (error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
if (errorType === 'unhandledRejection') {
substituteMsg +=
'\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)';
}
error = new Error(substituteMsg);
}
var handler = handlers[handlers.length - 1];
@@ -4423,7 +4592,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
* @example
* return expectAsync(aPromise).toBeResolved();
*/
return function toBeResolved() {
return function toBeResolved(matchersUtil) {
return {
compare: function(actual) {
if (!j$.isPromiseLike(actual)) {
@@ -4434,8 +4603,15 @@ getJasmineRequireObj().toBeResolved = function(j$) {
function() {
return { pass: true };
},
function() {
return { pass: false };
function(e) {
return {
pass: false,
message:
'Expected a promise to be resolved but it was ' +
'rejected with ' +
matchersUtil.pp(e) +
'.'
};
}
);
}
@@ -4490,10 +4666,14 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
};
}
},
function() {
function(e) {
return {
pass: false,
message: prefix(false) + ' but it was rejected.'
message:
prefix(false) +
' but it was rejected with ' +
matchersUtil.pp(e) +
'.'
};
}
);
@@ -4625,11 +4805,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// TODO: convert all uses of j$.pp to use the injected pp
/**
* @class MatchersUtil
* @classdesc Utilities for use in implementing matchers.<br>
* _Note:_ Do not construct this directly. Jasmine will construct one and
* pass it to matchers and asymmetric equality testers.
* @name MatchersUtil
* @classdesc Utilities for use in implementing matchers
* @constructor
* @hideconstructor
*/
function MatchersUtil(options) {
options = options || {};
@@ -4892,6 +5072,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
diffBuilder.recordMismatch();
}
return result;
case '[object ArrayBuffer]':
// If we have an instance of ArrayBuffer the Uint8Array ctor
// will be defined as well
return self.eq_(
new Uint8Array(a), // eslint-disable-line compat/compat
new Uint8Array(b), // eslint-disable-line compat/compat
aStack,
bStack,
customTesters,
diffBuilder
);
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return (
@@ -5268,6 +5459,31 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return MatchersUtil;
};
/**
* @interface AsymmetricEqualityTester
* @classdesc An asymmetric equality tester is an object that can match multiple
* objects. Examples include jasmine.any() and jasmine.stringMatching().
* User-defined asymmetric equality testers can also be defined and used in
* expectations.
* @see custom_asymmetric_equality_testers
* @since 2.0.0
*/
/**
* Determines whether a value matches this tester
* @function
* @name AsymmetricEqualityTester#asymmetricMatch
* @param value {any} The value to test
* @param matchersUtil {MatchersUtil} utilities for testing equality, etc
* @return {Boolean}
*/
/**
* Returns a string representation of this tester to use in matcher failure messages
* @function
* @name AsymmetricEqualityTester#jasmineToString
* @param pp {function} Function that takes a value and returns a pretty-printed representation
* @return {String}
*/
getJasmineRequireObj().MismatchTree = function(j$) {
/*
To be able to apply custom object formatters at all possible levels of an
@@ -7987,10 +8203,11 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {Object} obj - The object upon which to install the {@link Spy}s
* @param {boolean} includeNonEnumerable - Whether or not to add spies to non-enumerable properties
* @returns {Object} the spied object
*/
spyOnAllFunctions: function(obj) {
return env.spyOnAllFunctions(obj);
spyOnAllFunctions: function(obj, includeNonEnumerable) {
return env.spyOnAllFunctions(obj, includeNonEnumerable);
},
jsApiReporter: new jasmine.JsApiReporter({
@@ -8145,9 +8362,11 @@ getJasmineRequireObj().Spy = function(j$) {
});
/**
* _Note:_ Do not construct this directly, use {@link spyOn}, {@link spyOnProperty}, {@link jasmine.createSpy}, or {@link jasmine.createSpyObj}
* @constructor
* @name Spy
* @classdesc _Note:_ Do not construct this directly. Use {@link spyOn},
* {@link spyOnProperty}, {@link jasmine.createSpy}, or
* {@link jasmine.createSpyObj} instead.
* @class Spy
* @hideconstructor
*/
function Spy(
name,
@@ -8176,6 +8395,7 @@ getJasmineRequireObj().Spy = function(j$) {
* @property {object} object - `this` context for the invocation.
* @property {number} invocationOrder - Order of the invocation.
* @property {Array} args - The arguments passed for this invocation.
* @property returnValue - The value that was returned from this invocation.
*/
var callData = {
object: context,
@@ -8591,7 +8811,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
return spy;
};
this.spyOnAllFunctions = function(obj) {
this.spyOnAllFunctions = function(obj, includeNonEnumerable) {
if (j$.util.isUndefined(obj)) {
throw new Error(
'spyOnAllFunctions could not find an object to spy upon'
@@ -8599,30 +8819,27 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
}
var pointer = obj,
props = [],
prop,
descriptor;
propsToSpyOn = [],
properties,
propertiesToSkip = [];
while (pointer) {
for (prop in pointer) {
if (
Object.prototype.hasOwnProperty.call(pointer, prop) &&
pointer[prop] instanceof Function
) {
descriptor = Object.getOwnPropertyDescriptor(pointer, prop);
if (
(descriptor.writable || descriptor.set) &&
descriptor.configurable
) {
props.push(prop);
}
}
}
while (
pointer &&
(!includeNonEnumerable || pointer !== Object.prototype)
) {
properties = getProps(pointer, includeNonEnumerable);
properties = properties.filter(function(prop) {
return propertiesToSkip.indexOf(prop) === -1;
});
propertiesToSkip = propertiesToSkip.concat(properties);
propsToSpyOn = propsToSpyOn.concat(
getSpyableFunctionProps(pointer, properties)
);
pointer = Object.getPrototypeOf(pointer);
}
for (var i = 0; i < props.length; i++) {
this.spyOn(obj, props[i]);
for (var i = 0; i < propsToSpyOn.length; i++) {
this.spyOn(obj, propsToSpyOn[i]);
}
return obj;
@@ -8637,6 +8854,50 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
};
}
function getProps(obj, includeNonEnumerable) {
var enumerableProperties = Object.keys(obj);
if (!includeNonEnumerable) {
return enumerableProperties;
}
return Object.getOwnPropertyNames(obj).filter(function(prop) {
return (
prop !== 'constructor' ||
enumerableProperties.indexOf('constructor') > -1
);
});
}
function getSpyableFunctionProps(obj, propertiesToCheck) {
var props = [],
prop;
for (var i = 0; i < propertiesToCheck.length; i++) {
prop = propertiesToCheck[i];
if (
Object.prototype.hasOwnProperty.call(obj, prop) &&
isSpyableProp(obj, prop)
) {
props.push(prop);
}
}
return props;
}
function isSpyableProp(obj, prop) {
var value, descriptor;
try {
value = obj[prop];
} catch (e) {
return false;
}
if (value instanceof Function) {
descriptor = Object.getOwnPropertyDescriptor(obj, prop);
return (descriptor.writable || descriptor.set) && descriptor.configurable;
}
return false;
}
return SpyRegistry;
};
@@ -8969,10 +9230,26 @@ getJasmineRequireObj().StackTrace = function(j$) {
};
getJasmineRequireObj().Suite = function(j$) {
/**
* @interface Suite
* @see Env#topSuite
*/
function Suite(attrs) {
this.env = attrs.env;
this.id = attrs.id;
/**
* The parent of this suite, or null if this is the top suite.
* @name Suite#parentSuite
* @readonly
* @type {Suite}
*/
this.parentSuite = attrs.parentSuite;
/**
* The description passed to the {@link describe} that created this suite.
* @name Suite#description
* @readonly
* @type {string}
*/
this.description = attrs.description;
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
@@ -8986,6 +9263,11 @@ getJasmineRequireObj().Suite = function(j$) {
this.timer = attrs.timer || new j$.Timer();
/**
* The suite's children.
* @name Suite#children
* @type {Array.<(Spec|Suite)>}
*/
this.children = [];
/**
@@ -9023,6 +9305,12 @@ getJasmineRequireObj().Suite = function(j$) {
return this.asyncExpectationFactory(actual, this);
};
/**
* The full description including all ancestors of this suite.
* @name Suite#getFullName
* @function
* @returns {string}
*/
Suite.prototype.getFullName = function() {
var fullName = [];
for (
@@ -9469,5 +9757,5 @@ getJasmineRequireObj().UserContext = function(j$) {
};
getJasmineRequireObj().version = function() {
return '3.6.0';
return '3.8.0';
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "3.7.0"
VERSION = "3.8.0"
end
end

View File

@@ -1,13 +1,14 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "3.7.0",
"version": "3.8.0",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
},
"keywords": [
"test",
"testing",
"jasmine",
"tdd",
"bdd"
@@ -22,15 +23,20 @@
"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",
"grunt": "^1.0.4",
@@ -40,12 +46,11 @@
"grunt-css-url-embed": "^1.11.1",
"grunt-sass": "^3.0.2",
"jasmine": "^3.4.0",
"jasmine-browser-runner": "^0.4.0",
"jasmine-browser-runner": "github:jasmine/jasmine-browser#main",
"jsdom": "^15.0.0",
"load-grunt-tasks": "^4.0.0",
"node-sass": "^4.11.0",
"prettier": "1.17.1",
"selenium-webdriver": "^3.6.0",
"sass": "^1.32.12",
"shelljs": "^0.8.3",
"temp": "^0.9.0"
},

8
release_notes/3.7.1.md Normal file
View File

@@ -0,0 +1,8 @@
# Jasmine Core 3.7.1 Release Notes
## Summary
This is a bug fix release of Jasmine. It's identical to 3.7.0 except that it
correctly reports its version number. Please see the
[3.7.0 release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.7.0.md)
if you're upgrading directly from 3.6.0 or earlier.

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)_

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

@@ -0,0 +1,43 @@
#!/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 "internet explorer" 11
run_browser "internet explorer" 10
run_browser chrome latest
run_browser firefox latest
run_browser firefox 78
run_browser firefox 68
run_browser safari 14
run_browser safari 13
run_browser safari 9
run_browser safari 8
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

@@ -4,15 +4,41 @@ import json
with open('package.json') as packageFile:
version = json.load(packageFile)['version']
short_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.')
deprecation=('The Jasmine packages for Python are deprecated. There will be no further\n' +
'releases after the end of the Jasmine 3.x series. We recommend migrating to the\n' +
'following options:\n' +
'\n' +
'* jasmine-browser-runner (<https://github.com/jasmine/jasmine-browser>,\n' +
' `npm install jasmine-browser-runner`) to run specs in browsers, including\n' +
' headless Chrome and Saucelabs. This is the most direct replacement for the\n' +
' jasmine server` and `jasmine ci` commands provided by the `jasmine` Python\n' +
' package.\n' +
'* The jasmine npm package (<https://github.com/jasmine/jasmine-npm>,\n' +
' `npm install jasmine`) to run specs under Node.js.\n' +
'* The standalone distribution from the latest Jasmine release\n' +
' <https://github.com/jasmine/jasmine/releases> to run specs in browsers with\n' +
' no additional tools.\n' +
'* The jasmine-core npm package (`npm install jasmine-core`) if all you need is\n' +
' the Jasmine assets. This is the direct equivalent of the jasmine-core Python\n' +
' package.\n' +
'\n' +
'Except for the standalone distribution, all of the above are distributed through\n'
'npm.\n')
long_description = short_description + '\n\n' + deprecation
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.'),
description=short_description,
long_description=long_description,
long_description_content_type='text/plain',
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',

View File

@@ -96,8 +96,8 @@ describe('AsyncExpectation', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
return 'failure message';
pp: function(val) {
return val.toString();
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
@@ -114,7 +114,8 @@ 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.'
})
);
});
@@ -144,7 +145,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'."
})
);
});

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

@@ -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,7 +170,7 @@ describe('GlobalErrors', function() {
);
});
it('reports unhandledRejection in node.js', function() {
it('reports unhandled promise rejections in node.js', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
@@ -218,6 +218,38 @@ describe('GlobalErrors', function() {
);
});
it('reports unhandled promise rejections in node.js when no error is 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() {
it('subscribes and unsubscribes from the unhandledrejection event', function() {
var fakeGlobal = jasmine.createSpyObj('globalErrors', [

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

@@ -213,7 +213,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);

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();
});

View File

@@ -66,7 +66,6 @@ describe('asymmetricEqualityTesterArgCompatShim', function() {
'flatMap',
'includes',
'keys',
'toSource',
'values'
],
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []),

View File

@@ -46,9 +46,7 @@ describe('Any', function() {
});
it('matches a TypedArray', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var any = new jasmineUnderTest.Any(Uint32Array); // eslint-disable-line compat/compat
var any = new jasmineUnderTest.Any(Uint32Array);
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat
});

View File

@@ -40,8 +40,6 @@ describe('Anything', function() {
});
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

View File

@@ -42,7 +42,6 @@ describe('Empty', function() {
});
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

View File

@@ -44,7 +44,6 @@ describe('NotEmpty', function() {
});
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

View File

@@ -75,4 +75,33 @@ describe('base helpers', function() {
expect(jasmineUnderTest.isURL({})).toBe(false);
});
});
describe('isPending_', function() {
it('returns a promise that resolves to true when the promise is pending', function() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
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() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
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() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = Promise.reject();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false
);
});
});
});

View File

@@ -459,6 +459,10 @@ 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);
@@ -656,8 +660,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 +687,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,6 +1011,10 @@ 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) {
@@ -1147,6 +1155,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 +1197,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',
@@ -2819,6 +2835,10 @@ describe('Env integration', function() {
});
it('provides custom equality testers to async matchers', function(done) {
if (jasmine.getEnv().skipBrowserFlake) {
jasmine.getEnv().skipBrowserFlake();
}
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone');
@@ -2883,6 +2903,8 @@ describe('Env integration', function() {
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 +2914,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();
@@ -2938,6 +2966,8 @@ describe('Env integration', function() {
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 +2978,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();

View File

@@ -754,4 +754,89 @@ 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) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
// eslint-disable-next-line compat/compat
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) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return (
env
// eslint-disable-next-line compat/compat
.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) {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
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

@@ -15,12 +15,19 @@ describe('toBeResolved', function() {
it('fails if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter([])
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec rejection');
actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
return matcher.compare(actual).then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
expect(result).toEqual({
pass: false,
message:
'Expected a promise to be resolved but it was rejected ' +
'with Error: AsyncExpectationSpec rejection.'
});
});
});

View File

@@ -19,14 +19,15 @@ describe('#toBeResolvedTo', function() {
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec error');
actual = Promise.reject(new Error('AsyncExpectationSpec error'));
return matcher.compare(actual, '').then(function(result) {
expect(result).toEqual(
jasmine.objectContaining({
pass: false,
message:
"Expected a promise to be resolved to '' but it was rejected."
"Expected a promise to be resolved to '' but it was rejected " +
'with Error: AsyncExpectationSpec error.'
})
);
});

View File

@@ -885,6 +885,164 @@ describe('matchersUtil', function() {
);
});
it('passes for ArrayBuffers with same length and content', function() {
jasmine.getEnv().requireFunctioningArrayBuffers();
var buffer1 = new ArrayBuffer(4); // eslint-disable-line compat/compat
var buffer2 = new ArrayBuffer(4); // eslint-disable-line compat/compat
expect(jasmineUnderTest.matchersUtil.equals(buffer1, buffer2)).toBe(true);
});
it('fails for ArrayBuffers with same length but different content', function() {
jasmine.getEnv().requireFunctioningArrayBuffers();
var buffer1 = new ArrayBuffer(4); // eslint-disable-line compat/compat
var buffer2 = new ArrayBuffer(4); // eslint-disable-line compat/compat
var array1 = new Uint8Array(buffer1); // eslint-disable-line compat/compat
array1[0] = 1;
expect(jasmineUnderTest.matchersUtil.equals(buffer1, buffer2)).toBe(
false
);
});
describe('Typed arrays', function() {
it('fails for typed arrays of same length and contents but different types', function() {
// eslint-disable-next-line compat/compat
var a1 = new Int8Array(1);
// eslint-disable-next-line compat/compat
var a2 = new Uint8Array(1);
a1[0] = a2[0] = 0;
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
});
// eslint-disable-next-line compat/compat
[
'Int8Array',
'Uint8Array',
'Uint8ClampedArray',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
].forEach(function(typeName) {
function requireType() {
var TypedArrayCtor = jasmine.getGlobal()[typeName];
if (!TypedArrayCtor) {
pending('Browser does not support ' + typeName);
}
return TypedArrayCtor;
}
it(
'passes for ' + typeName + 's with same length and content',
function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
a1[0] = a2[0] = 0;
a1[1] = a2[1] = 1;
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(true);
}
);
it('fails for ' + typeName + 's with different length', function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1);
a1[0] = a1[1] = a2[0] = 0;
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
});
it(
'fails for ' + typeName + 's with same length but different content',
function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
a1[0] = 0;
a2[0] = 1;
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
}
);
it('checks nonstandard properties of ' + typeName, function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
a1[0] = a2[0] = 0;
a1.extra = 'yes';
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
});
it('works with custom equality testers with ' + typeName, function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [
function() {
return true;
}
]
});
a1[0] = 0;
a2[0] = 1;
expect(matchersUtil.equals(a1, a2)).toBe(true);
});
});
['BigInt64Array', 'BigUint64Array'].forEach(function(typeName) {
function requireType() {
var TypedArrayCtor = jasmine.getGlobal()[typeName];
if (!TypedArrayCtor) {
pending('Browser does not support ' + typeName);
}
return TypedArrayCtor;
}
it(
'passes for ' + typeName + 's with same length and content',
function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
// eslint-disable-next-line compat/compat
a1[0] = a2[0] = BigInt(0);
// eslint-disable-next-line compat/compat
a1[1] = a2[1] = BigInt(1);
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(true);
}
);
it('fails for ' + typeName + 's with different length', function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1);
// eslint-disable-next-line compat/compat
a1[0] = a1[1] = a2[0] = BigInt(0);
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
});
it(
'fails for ' + typeName + 's with same length but different content',
function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
// eslint-disable-next-line compat/compat
a1[0] = a1[1] = a2[0] = BigInt(0);
// eslint-disable-next-line compat/compat
a2[1] = BigInt(1);
expect(jasmineUnderTest.matchersUtil.equals(a1, a2)).toBe(false);
}
);
});
});
describe('when running in an environment with array polyfills', function() {
var findIndexDescriptor = Object.getOwnPropertyDescriptor(
Array.prototype,

View File

@@ -257,8 +257,6 @@ describe('toEqual', function() {
});
it('reports mismatches between arrays of different types', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var actual = new Uint32Array([1, 2, 3]), // eslint-disable-line compat/compat
expected = new Uint16Array([1, 2, 3]), // eslint-disable-line compat/compat
message =

View File

@@ -0,0 +1,24 @@
/* eslint-disable compat/compat */
(function(env) {
function hasFunctioningArrayBuffers() {
if (typeof ArrayBuffer === 'undefined') {
return false;
}
try {
var buffer = new ArrayBuffer(2);
var view8bit = new Uint8Array(buffer);
var view16bit = new Uint16Array(buffer);
view16bit[0] = 0xabcd;
return view8bit[0] === 0xcd && view8bit[1] === 0xab;
} catch (e) {
return false;
}
}
env.requireFunctioningArrayBuffers = function() {
if (!hasFunctioningArrayBuffers()) {
env.pending('Browser has incomplete or missing support for ArrayBuffer');
}
};
})(jasmine.getEnv());

View File

@@ -1,24 +0,0 @@
/* eslint-disable compat/compat */
(function(env) {
function hasFunctioningTypedArrays() {
if (typeof Uint32Array === 'undefined') {
return false;
}
try {
var a = new Uint32Array([1, 2, 3]);
if (a.length !== 3) {
return false;
}
return true;
} catch (e) {
return false;
}
}
env.requireFunctioningTypedArrays = function() {
if (!hasFunctioningTypedArrays()) {
env.pending('Browser has incomplete or missing support for typed arrays');
}
};
})(jasmine.getEnv());

View File

@@ -0,0 +1,7 @@
(function(env) {
env.skipBrowserFlake = function() {
pending(
'Skipping specs that are known to be flaky in browsers in this run'
);
};
})(jasmine.getEnv());

View File

@@ -484,7 +484,7 @@ describe('HtmlReporter', function() {
var suiteDetail = outerSuite.childNodes[0];
var suiteLink = suiteDetail.childNodes[0];
expect(suiteLink.innerHTML).toEqual('A Suite');
expect(suiteLink.getAttribute('href')).toEqual('?foo=bar&spec=A Suite');
expect(suiteLink.getAttribute('href')).toEqual('/?foo=bar&spec=A Suite');
var specs = outerSuite.childNodes[1];
var spec = specs.childNodes[0];
@@ -494,7 +494,7 @@ describe('HtmlReporter', function() {
var specLink = spec.childNodes[0];
expect(specLink.innerHTML).toEqual('with a spec');
expect(specLink.getAttribute('href')).toEqual(
'?foo=bar&spec=A Suite with a spec'
'/?foo=bar&spec=A Suite with a spec'
);
});
@@ -802,7 +802,7 @@ describe('HtmlReporter', function() {
var throwingExpectationsUI = container.querySelector('.jasmine-throw');
throwingExpectationsUI.click();
expect(navigateHandler).toHaveBeenCalledWith('throwFailures', true);
expect(navigateHandler).toHaveBeenCalledWith('oneFailurePerSpec', true);
});
it('should navigate and change the setting to off', function() {
@@ -831,7 +831,10 @@ describe('HtmlReporter', function() {
var throwingExpectationsUI = container.querySelector('.jasmine-throw');
throwingExpectationsUI.click();
expect(navigateHandler).toHaveBeenCalledWith('throwFailures', false);
expect(navigateHandler).toHaveBeenCalledWith(
'oneFailurePerSpec',
false
);
});
});
describe('UI for hiding disabled specs', function() {
@@ -1047,7 +1050,7 @@ describe('HtmlReporter', function() {
var seedBar = container.querySelector('.jasmine-seed-bar');
expect(seedBar.textContent).toBe(', randomized with seed 424242');
var seedLink = container.querySelector('.jasmine-seed-bar a');
expect(seedLink.getAttribute('href')).toBe('?seed=424242');
expect(seedLink.getAttribute('href')).toBe('/?seed=424242');
});
it('should not show the current seed bar if not randomizing', function() {
@@ -1096,7 +1099,7 @@ describe('HtmlReporter', function() {
reporter.jasmineDone({ order: { random: true } });
var skippedLink = container.querySelector('.jasmine-skipped a');
expect(skippedLink.getAttribute('href')).toEqual('?foo=bar&spec=');
expect(skippedLink.getAttribute('href')).toEqual('/?foo=bar&spec=');
});
});

View File

@@ -99,4 +99,65 @@ describe('npm package', function() {
expect(images).toContain('jasmine-horizontal.svg');
expect(images).toContain('jasmine_favicon.png');
});
it('does not have CI config files and scripts', function() {
expect(fs.existsSync(path.resolve(this.tmpDir, 'package/.circleci'))).toBe(
false
);
expect(fs.existsSync(path.resolve(this.tmpDir, 'package/scripts'))).toBe(
false
);
});
it('does not have any unexpected files in the root directory', function() {
var files = fs.readdirSync(this.tmpDir);
expect(files).toEqual(['package']);
});
it('does not have any unexpected files in the package directory', function() {
var files = fs.readdirSync(path.resolve(this.tmpDir, 'package'));
files.sort();
expect(files).toEqual([
'MIT.LICENSE',
'README.md',
'images',
'lib',
'package.json'
]);
});
it('only has images in the images dir', function() {
var files = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')),
i;
for (i = 0; i < files.length; i++) {
expect(files[i]).toMatch(/\.(svg|png)$/);
}
});
it('only has JS and CSS files in the lib dir', function() {
var files = [],
i;
function getFiles(dir) {
var dirents = fs.readdirSync(dir, { withFileTypes: true }),
j;
for (j = 0; j < dirents.length; j++) {
dirent = dirents[j];
if (dirent.isDirectory()) {
getFiles(path.resolve(dir, dirent.name));
} else {
files.push(path.resolve(dir, dirent.name));
}
}
}
getFiles(path.resolve(this.tmpDir, 'package/lib'));
for (i = 0; i < files.length; i++) {
expect(files[i]).toMatch(/\.(js|css)$/);
}
});
});

View File

@@ -20,10 +20,10 @@ module.exports = {
'helpers/asyncAwait.js',
'helpers/generator.js',
'helpers/BrowserFlags.js',
'helpers/checkForArrayBuffer.js',
'helpers/checkForMap.js',
'helpers/checkForSet.js',
'helpers/checkForSymbol.js',
'helpers/checkForTypedArrays.js',
'helpers/checkForUrl.js',
'helpers/domHelpers.js',
'helpers/integrationMatchers.js',
@@ -41,11 +41,13 @@ module.exports = {
browserVersion: process.env.SAUCE_BROWSER_VERSION,
build: `Core ${process.env.TRAVIS_BUILD_NUMBER || 'Ran locally'}`,
tags: ['Jasmine-Core'],
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
? process.env.TRAVIS_JOB_NUMBER.toString()
: null,
tunnelIdentifier: process.env.SAUCE_TUNNEL_IDENTIFIER,
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY
}
}
};
if (process.env.SKIP_JASMINE_BROWSER_FLAKES === 'true') {
module.exports.helpers.push('helpers/disableBrowserFlakes.js');
}

View File

@@ -7,15 +7,16 @@
"helpers": [
"helpers/asyncAwait.js",
"helpers/generator.js",
"helpers/checkForArrayBuffer.js",
"helpers/checkForMap.js",
"helpers/checkForSet.js",
"helpers/checkForSymbol.js",
"helpers/checkForTypedArrays.js",
"helpers/checkForUrl.js",
"helpers/domHelpers.js",
"helpers/integrationMatchers.js",
"helpers/promises.js",
"helpers/requireFastCheck.js",
"helpers/overrideConsoleLogForCircleCi.js",
"helpers/nodeDefineJasmineUnderTest.js"
],
"random": true

View File

@@ -49,6 +49,18 @@ getJasmineRequireObj().CallTracker = function(j$) {
return call ? call.args : [];
};
/**
* Get the "this" object that was passed to a specific invocation of this spy.
* @name Spy#calls#thisFor
* @function
* @param {Integer} index The 0-based invocation index.
* @return {Object?}
*/
this.thisFor = function(index) {
var call = calls[index];
return call ? call.object : undefined;
};
/**
* Get the raw calls array for this spy.
* @name Spy#calls#all

View File

@@ -6,9 +6,11 @@ getJasmineRequireObj().Clock = function() {
typeof process.versions.node === 'string';
/**
* _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
* @class Clock
* @classdesc Jasmine's mock clock is used when testing time dependent code.
* @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
* _Note:_ Do not construct this directly. You can get the current clock with
* {@link jasmine.clock}.
* @hideconstructor
*/
function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
var self = this,

View File

@@ -1,10 +1,11 @@
getJasmineRequireObj().Env = function(j$) {
/**
* _Note:_ Do not construct this directly, Jasmine will make one during booting.
* @name Env
* @class Env
* @since 2.0.0
* @classdesc The Jasmine environment
* @constructor
* @classdesc The Jasmine environment.<br>
* _Note:_ Do not construct this directly. You can obtain the Env instance by
* calling {@link jasmine.getEnv}.
* @hideconstructor
*/
function Env(options) {
options = options || {};
@@ -35,7 +36,8 @@ getJasmineRequireObj().Env = function(j$) {
/**
* This represents the available options to configure Jasmine.
* Options that are not provided will use their default values
* Options that are not provided will use their default values.
* @see Env#configure
* @interface Configuration
* @since 3.3.0
*/
@@ -53,7 +55,7 @@ getJasmineRequireObj().Env = function(j$) {
* Null causes the seed to be determined randomly at the start of execution.
* @name Configuration#seed
* @since 3.3.0
* @type function
* @type (number|string)
* @default null
*/
seed: null,
@@ -83,12 +85,19 @@ getJasmineRequireObj().Env = function(j$) {
* @default false
*/
oneFailurePerSpec: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
* @callback SpecFilter
* @param {Spec} spec - The spec that the filter is being applied to.
* @return boolean
*/
/**
* Function to use to filter specs
* @name Configuration#specFilter
* @since 3.3.0
* @type function
* @default true
* @type SpecFilter
* @default A function that always returns true.
*/
specFilter: function() {
return true;
@@ -639,6 +648,13 @@ getJasmineRequireObj().Env = function(j$) {
defaultResourcesForRunnable(topSuite.id);
currentDeclarationSuite = topSuite;
/**
* Provides the root suite, through which all suites and specs can be
* accessed.
* @function
* @name Env#topSuite
* @return {Suite} the root suite
*/
this.topSuite = function() {
return topSuite;
};
@@ -718,7 +734,27 @@ getJasmineRequireObj().Env = function(j$) {
queueRunnerFactory
);
// Both params are optional.
/**
* Executes the specs.
*
* If called with no parameters or with a falsy value as the first parameter,
* all specs will be executed except those that are excluded by a
* [spec filter]{@link Configuration#specFilter} or other mechanism. If the
* first parameter is a list of spec/suite IDs, only those specs/suites will
* be run.
*
* Both parameters are optional, but a completion callback is only valid as
* the second parameter. To specify a completion callback but not a list of
* specs/suites to run, pass null or undefined as the first parameter.
*
* execute should not be called more than once.
*
* @name Env#execute
* @since 2.0.0
* @function
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
* @param {Function=} onComplete Function that will be called after all specs have run
*/
this.execute = function(runnablesToRun, onComplete) {
installGlobalErrors();
@@ -910,6 +946,15 @@ getJasmineRequireObj().Env = function(j$) {
}
});
/**
* Configures whether Jasmine should allow the same function to be spied on
* more than once during the execution of a spec. By default, spying on
* a function that is already a spy will cause an error.
* @name Env#allowRespy
* @function
* @since 2.5.0
* @param {boolean} allow Whether to allow respying
*/
this.allowRespy = function(allow) {
spyRegistry.allowRespy(allow);
};

View File

@@ -43,7 +43,35 @@ getJasmineRequireObj().Expectation = function(j$) {
});
/**
* Asynchronous matchers.
* Asynchronous matchers that operate on an actual value which is a promise,
* and return a promise.
*
* Most async matchers will wait indefinitely for the promise to be resolved
* or rejected, resulting in a spec timeout if that never happens. If you
* expect that the promise will already be resolved or rejected at the time
* the matcher is called, you can use the {@link async-matchers#already}
* modifier to get a faster failure with a more helpful message.
*
* Note: Specs must await the result of each async matcher, return the
* promise returned by the matcher, or return a promise that's derived from
* the one returned by the matcher. Otherwise the matcher will not be
* evaluated before the spec completes.
*
* @example
* // Good
* await expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved()
* .then(function() {
* // more spec code
* });
* @example
* // Bad
* expectAsync(aPromise).toBeResolved();
* @namespace async-matchers
*/
function AsyncExpectation(options) {
@@ -93,6 +121,23 @@ getJasmineRequireObj().Expectation = function(j$) {
}
});
/**
* Fail as soon as possible if the actual is pending.
* Otherwise evaluate the matcher.
* @member
* @name async-matchers#already
* @type {async-matchers}
* @example
* await expectAsync(myPromise).already.toBeResolved();
* @example
* return expectAsync(myPromise).already.toBeResolved();
*/
Object.defineProperty(AsyncExpectation.prototype, 'already', {
get: function() {
return addFilter(this, expectSettledPromiseFilter);
}
});
function wrapSyncCompare(name, matcherFactory) {
return function() {
var result = this.expector.compare(name, matcherFactory, arguments);
@@ -171,6 +216,27 @@ getJasmineRequireObj().Expectation = function(j$) {
buildFailureMessage: negatedFailureMessage
};
var expectSettledPromiseFilter = {
selectComparisonFunc: function(matcher) {
return function(actual) {
var matcherArgs = arguments;
return j$.isPending_(actual).then(function(isPending) {
if (isPending) {
return {
pass: false,
message:
'Expected a promise to be settled (via ' +
'expectAsync(...).already) but it was pending.'
};
} else {
return matcher.compare.apply(null, matcherArgs);
}
});
};
}
};
function ContextAddingFilter(message) {
this.message = message;
}

View File

@@ -17,7 +17,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
this.jasmineHandlers = {};
this.installOne_ = function installOne_(errorType, jasmineMessage) {
function taggedOnError(error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
var substituteMsg;
if (error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
if (errorType === 'unhandledRejection') {
substituteMsg +=
'\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)';
}
error = new Error(substituteMsg);
}
var handler = handlers[handlers.length - 1];

View File

@@ -1,9 +1,19 @@
getJasmineRequireObj().Spec = function(j$) {
/**
* @interface Spec
* @see Configuration#specFilter
*/
function Spec(attrs) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id;
/**
* The description passed to the {@link it} that created this spec.
* @name Spec#description
* @readonly
* @type {string}
*/
this.description = attrs.description || '';
this.queueableFn = attrs.queueableFn;
this.beforeAndAfterFns =
@@ -195,6 +205,12 @@ getJasmineRequireObj().Spec = function(j$) {
return 'passed';
};
/**
* The full description including all ancestors of this spec.
* @name Spec#getFullName
* @function
* @returns {string}
*/
Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};

View File

@@ -13,9 +13,11 @@ getJasmineRequireObj().Spy = function(j$) {
});
/**
* _Note:_ Do not construct this directly, use {@link spyOn}, {@link spyOnProperty}, {@link jasmine.createSpy}, or {@link jasmine.createSpyObj}
* @constructor
* @name Spy
* @classdesc _Note:_ Do not construct this directly. Use {@link spyOn},
* {@link spyOnProperty}, {@link jasmine.createSpy}, or
* {@link jasmine.createSpyObj} instead.
* @class Spy
* @hideconstructor
*/
function Spy(
name,
@@ -44,6 +46,7 @@ getJasmineRequireObj().Spy = function(j$) {
* @property {object} object - `this` context for the invocation.
* @property {number} invocationOrder - Order of the invocation.
* @property {Array} args - The arguments passed for this invocation.
* @property returnValue - The value that was returned from this invocation.
*/
var callData = {
object: context,

View File

@@ -163,7 +163,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
return spy;
};
this.spyOnAllFunctions = function(obj) {
this.spyOnAllFunctions = function(obj, includeNonEnumerable) {
if (j$.util.isUndefined(obj)) {
throw new Error(
'spyOnAllFunctions could not find an object to spy upon'
@@ -171,30 +171,27 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
}
var pointer = obj,
props = [],
prop,
descriptor;
propsToSpyOn = [],
properties,
propertiesToSkip = [];
while (pointer) {
for (prop in pointer) {
if (
Object.prototype.hasOwnProperty.call(pointer, prop) &&
pointer[prop] instanceof Function
) {
descriptor = Object.getOwnPropertyDescriptor(pointer, prop);
if (
(descriptor.writable || descriptor.set) &&
descriptor.configurable
) {
props.push(prop);
}
}
}
while (
pointer &&
(!includeNonEnumerable || pointer !== Object.prototype)
) {
properties = getProps(pointer, includeNonEnumerable);
properties = properties.filter(function(prop) {
return propertiesToSkip.indexOf(prop) === -1;
});
propertiesToSkip = propertiesToSkip.concat(properties);
propsToSpyOn = propsToSpyOn.concat(
getSpyableFunctionProps(pointer, properties)
);
pointer = Object.getPrototypeOf(pointer);
}
for (var i = 0; i < props.length; i++) {
this.spyOn(obj, props[i]);
for (var i = 0; i < propsToSpyOn.length; i++) {
this.spyOn(obj, propsToSpyOn[i]);
}
return obj;
@@ -209,5 +206,49 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
};
}
function getProps(obj, includeNonEnumerable) {
var enumerableProperties = Object.keys(obj);
if (!includeNonEnumerable) {
return enumerableProperties;
}
return Object.getOwnPropertyNames(obj).filter(function(prop) {
return (
prop !== 'constructor' ||
enumerableProperties.indexOf('constructor') > -1
);
});
}
function getSpyableFunctionProps(obj, propertiesToCheck) {
var props = [],
prop;
for (var i = 0; i < propertiesToCheck.length; i++) {
prop = propertiesToCheck[i];
if (
Object.prototype.hasOwnProperty.call(obj, prop) &&
isSpyableProp(obj, prop)
) {
props.push(prop);
}
}
return props;
}
function isSpyableProp(obj, prop) {
var value, descriptor;
try {
value = obj[prop];
} catch (e) {
return false;
}
if (value instanceof Function) {
descriptor = Object.getOwnPropertyDescriptor(obj, prop);
return (descriptor.writable || descriptor.set) && descriptor.configurable;
}
return false;
}
return SpyRegistry;
};

View File

@@ -1,8 +1,24 @@
getJasmineRequireObj().Suite = function(j$) {
/**
* @interface Suite
* @see Env#topSuite
*/
function Suite(attrs) {
this.env = attrs.env;
this.id = attrs.id;
/**
* The parent of this suite, or null if this is the top suite.
* @name Suite#parentSuite
* @readonly
* @type {Suite}
*/
this.parentSuite = attrs.parentSuite;
/**
* The description passed to the {@link describe} that created this suite.
* @name Suite#description
* @readonly
* @type {string}
*/
this.description = attrs.description;
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
@@ -16,6 +32,11 @@ getJasmineRequireObj().Suite = function(j$) {
this.timer = attrs.timer || new j$.Timer();
/**
* The suite's children.
* @name Suite#children
* @type {Array.<(Spec|Suite)>}
*/
this.children = [];
/**
@@ -53,6 +74,12 @@ getJasmineRequireObj().Suite = function(j$) {
return this.asyncExpectationFactory(actual, this);
};
/**
* The full description including all ancestors of this suite.
* @name Suite#getFullName
* @function
* @returns {string}
*/
Suite.prototype.getFullName = function() {
var fullName = [];
for (

View File

@@ -203,6 +203,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return matches ? matches[1] : '<anonymous>';
};
j$.isPending_ = function(promise) {
var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) {
return result === sentinel;
},
function() {
return false;
}
);
};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is an instance of the specified class/constructor.

View File

@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
* @example
* return expectAsync(aPromise).toBeResolved();
*/
return function toBeResolved() {
return function toBeResolved(matchersUtil) {
return {
compare: function(actual) {
if (!j$.isPromiseLike(actual)) {
@@ -21,8 +21,15 @@ getJasmineRequireObj().toBeResolved = function(j$) {
function() {
return { pass: true };
},
function() {
return { pass: false };
function(e) {
return {
pass: false,
message:
'Expected a promise to be resolved but it was ' +
'rejected with ' +
matchersUtil.pp(e) +
'.'
};
}
);
}

View File

@@ -45,10 +45,14 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
};
}
},
function() {
function(e) {
return {
pass: false,
message: prefix(false) + ' but it was rejected.'
message:
prefix(false) +
' but it was rejected with ' +
matchersUtil.pp(e) +
'.'
};
}
);

View File

@@ -2,11 +2,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// TODO: convert all uses of j$.pp to use the injected pp
/**
* @class MatchersUtil
* @classdesc Utilities for use in implementing matchers.<br>
* _Note:_ Do not construct this directly. Jasmine will construct one and
* pass it to matchers and asymmetric equality testers.
* @name MatchersUtil
* @classdesc Utilities for use in implementing matchers
* @constructor
* @hideconstructor
*/
function MatchersUtil(options) {
options = options || {};
@@ -269,6 +269,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
diffBuilder.recordMismatch();
}
return result;
case '[object ArrayBuffer]':
// If we have an instance of ArrayBuffer the Uint8Array ctor
// will be defined as well
return self.eq_(
new Uint8Array(a), // eslint-disable-line compat/compat
new Uint8Array(b), // eslint-disable-line compat/compat
aStack,
bStack,
customTesters,
diffBuilder
);
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return (
@@ -644,3 +655,28 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return MatchersUtil;
};
/**
* @interface AsymmetricEqualityTester
* @classdesc An asymmetric equality tester is an object that can match multiple
* objects. Examples include jasmine.any() and jasmine.stringMatching().
* User-defined asymmetric equality testers can also be defined and used in
* expectations.
* @see custom_asymmetric_equality_testers
* @since 2.0.0
*/
/**
* Determines whether a value matches this tester
* @function
* @name AsymmetricEqualityTester#asymmetricMatch
* @param value {any} The value to test
* @param matchersUtil {MatchersUtil} utilities for testing equality, etc
* @return {Boolean}
*/
/**
* Returns a string representation of this tester to use in matcher failure messages
* @function
* @name AsymmetricEqualityTester#jasmineToString
* @param pp {function} Function that takes a value and returns a pretty-printed representation
* @return {String}
*/

View File

@@ -285,10 +285,11 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {Object} obj - The object upon which to install the {@link Spy}s
* @param {boolean} includeNonEnumerable - Whether or not to add spies to non-enumerable properties
* @returns {Object} the spied object
*/
spyOnAllFunctions: function(obj) {
return env.spyOnAllFunctions(obj);
spyOnAllFunctions: function(obj, includeNonEnumerable) {
return env.spyOnAllFunctions(obj, includeNonEnumerable);
},
jsApiReporter: new jasmine.JsApiReporter({

View File

@@ -177,7 +177,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',
@@ -534,7 +537,7 @@ jasmineRequire.HtmlReporter = function(j$) {
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.onclick = function() {
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
};
var randomCheckbox = optionsMenuDom.querySelector(
@@ -604,7 +607,11 @@ 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) {
@@ -668,11 +675,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) {

View File

@@ -1,12 +0,0 @@
#!/bin/bash -e
if [ $USE_SAUCE == true ]
then
if [ $TRAVIS_SECURE_ENV_VARS != true ]
then
echo "skipping tests since we can't use sauce"
exit 0
fi
fi
npm run ci