Compare commits

...

73 Commits

Author SHA1 Message Date
Gregg Van Hove
a95c2cfe3f Bump version to 2.4.1 2015-12-03 16:06:51 -08:00
Gregg Van Hove
e2e2d1b343 Revert #908
- Run `afterEach` in reverse order declared as before
2015-12-03 16:02:32 -08:00
Gregg Van Hove
3b53e469fd Bump version to 2.4.0 2015-12-02 22:02:03 -08:00
Gregg Van Hove
b3f69852c1 Merge pull request #973 from brunoqc/patch-1
Syntax highlighting in README.md
2015-11-13 17:05:28 -08:00
Bruno Bigras
1613a376b1 Syntax highlighting in README.md 2015-11-12 12:10:21 -05:00
Gregg Van Hove
1e35e8ba95 Use git:// url for jasmine-npm dependency 2015-11-04 15:12:38 -08:00
Gregg Van Hove
a6b209bc2f Use jasmine-npm straight from github when developing 2015-11-04 15:05:07 -08:00
Gregg Van Hove
2301914549 build combined file for jsApiReporter changes
[#92249258]
2015-11-04 14:11:39 -08:00
Gregg Van Hove
320c42b6cc Run jasmine's specs randomly in node and performance specs
[#92249258]
2015-11-04 12:30:49 -08:00
Gregg Van Hove
df45b4fede Run jasmine's specs in random order
[#92249258]
2015-11-04 12:06:28 -08:00
Gregg Van Hove
c1ab3c9cbe Add support for returning run details for reporting randomness
[#92249258]
2015-11-04 12:05:29 -08:00
Gregg Van Hove
d2f2e2b870 Merge branch 'himajasuman-issue#896'
Fixes #896
2015-10-27 14:13:15 -07:00
Gregg Van Hove
0f6a7f04b3 Merge branch 'issue#896' of https://github.com/himajasuman/jasmine into himajasuman-issue#896 2015-10-27 14:12:31 -07:00
Gregg Van Hove
728af5e556 Remove unused queueableFn arg from onException
Fixes #958
2015-10-27 12:24:32 -07:00
Gregg Van Hove
018fd53c10 Merge branch 'FuzzySockets-to-throw-error-unused-param' 2015-10-27 12:22:09 -07:00
Gregg Van Hove
25d73515f3 Merge branch 'to-throw-error-unused-param' of https://github.com/FuzzySockets/jasmine into FuzzySockets-to-throw-error-unused-param 2015-10-27 12:21:42 -07:00
Gregg Van Hove
8e317d4026 Less verbose for the linter 2015-10-26 17:51:42 -07:00
Gregg Van Hove
ea4c44904d IE 8 doesn't support defineProperty on non-DOM nodes, skip that kindof thing 2015-10-26 17:41:30 -07:00
Gregg Van Hove
77514bbb80 use safari 9 not 8.1 anymore 2015-10-26 17:18:25 -07:00
Gregg Van Hove
a85c3a4da8 Check for descriptor 2015-10-26 17:03:45 -07:00
Gregg Van Hove
0b1e1a0401 Merge branch 'StephanBijzitter-throw-for-constants'
Fixes #948
2015-10-26 16:30:01 -07:00
Gregg Van Hove
3374415add Merge pull request #954 from matthewhuff89/remove_goals_md
Removed GOALS_2.0.md, doesn't seem to be needed anymore
2015-10-26 14:58:03 -07:00
Richard Harrington
c2ae3b6b12 Remove unused parameter from toThrowError 2015-10-26 11:43:31 -04:00
Himaja
110cacab19 Added a throw error block in describe incase a function with arguments is passed in describe 2015-10-25 14:13:14 -04:00
Matthew D. Huff
db7879a478 Removed GOALS_2.0.md, doesn't seem to be needed anymore 2015-10-25 13:03:46 -04:00
Stephan Bijzitter
a81466d9e7 Abort spying when the target cannot be spied on 2015-10-21 12:44:52 +02:00
Gregg Van Hove
48f42eaa7d Merge branch 'lalunamel-master'
Merges #942
Fixes #930
Fixes #912
2015-10-15 09:21:57 -07:00
Cody Sehl
e5c2572753 Change #xit so that it will output a more BDD-style pending message 2015-10-14 21:03:47 -06:00
Gregg Van Hove
141fd910f2 Use className instead of class when creating DOM elements 2015-10-06 09:10:22 -07:00
Gregg Van Hove
a93bfd2120 Merge branch 'marcioj-random-tests' 2015-10-04 14:03:30 -07:00
Gregg Van Hove
4221b2d2c4 Merge branch 'random-tests' of https://github.com/marcioj/jasmine into marcioj-random-tests 2015-10-04 14:03:17 -07:00
Gregg Van Hove
6ee7fd6ced Merge branch 'toString_fallback' of https://github.com/myitcv/jasmine into myitcv-toString_fallback 2015-10-04 13:47:27 -07:00
Gregg Van Hove
878325e2cf Merge branch 'James-Dunn-patch-1' 2015-10-04 13:45:10 -07:00
James
80c4f87dd5 Fix circles/x from getting cut off on Mac/chrome 2015-09-27 17:01:08 +04:00
Marcio Junior
3f3fa484b2 Allow tests to run in random order 2015-09-26 14:53:08 -03:00
Paul Jolly
d0ad9b98cd Use toString for objects if it has been overriden 2015-09-25 20:19:48 +01:00
Gregg Van Hove
375a6f9fda Merge branch 'danielalexiuc-master'
- Fixes #924
- Fixes #917
2015-09-24 12:58:56 -07:00
danielalexiuc
c017f0000d Postpone find() until it is needed
This is a fix for issue #917.

It seems that 'symbols' was originally included as a performance optimization, to avoid repeated find() calls for '.jasmine-symbol-summary'. However this find() occasionally fails during initialize if the dom has not loaded completely.

This change will not affect performance, as symbols is still cached. However it improves upon the original code in that the find happens at a stage much later than initialize.
2015-09-16 11:52:05 +10:00
Gregg Van Hove
4097718b66 Merge pull request #906 from soycode/master
check for global before assigning
2015-09-03 13:38:21 -07:00
Gregg Van Hove
825dab32ff Merge pull request #908 from mcamac/master
Reverse suite afterEach behavior to match semantics?
2015-09-01 21:33:52 -07:00
Martin Camacho
f3a7396845 afterEach behavior 2015-08-18 17:55:03 -04:00
soycode
850bee5492 check for global before assigning 2015-08-17 14:20:52 -07:00
Gregg Van Hove
6028a5d92c Merge branch 'SimenB-badges' 2015-08-10 10:39:39 -07:00
Simen Bekkhus
93a13ab791 Use badges from shields.io 2015-08-08 07:54:15 +02:00
Greg Chattin-McNichols and Gregg Van Hove
542f483228 Force the safari 8.1 version to be a string for sauce 2015-08-04 15:11:39 -07:00
Greg Chattin-McNichols and Gregg Van Hove
459b4c29b6 Drop Safari 5 on OS-X from the build matrix
- SauceLabs no longer supports it
- Add Safari 8.1
2015-08-04 09:40:37 -07:00
Greg Chattin-McNichols and Gregg Van Hove
750a9aac6d Merge pull request #869 from ljwall/jasmine
Fixes #855
2015-08-03 15:01:43 -07:00
Greg Chattin-McNichols and Gregg Van Hove
cd55f03912 concat files for toHaveBeenCalledTimes matcher 2015-08-03 14:57:52 -07:00
Gregg Van Hove
79954311fb Merge pull request #892 from obastemur/patch-1
Update glob to latest
2015-07-16 12:10:21 -07:00
Oguz Bastemur
3f71bcdb2d Update glob to latest
Fixes https://github.com/jasmine/jasmine/issues/891
2015-07-15 02:37:36 +03:00
Gregg Van Hove
06f05ac57b Add notes about "ready for work" label 2015-07-02 14:52:17 -07:00
Gregg Van Hove
5ea5ec6004 Merge branch 'kkirsche-patch-1' 2015-06-12 13:25:37 -07:00
Kevin Kirsche
f7033f6551 Remove moot version property from bower.json
Per bower/bower.json-spec@a325da3
2015-06-10 18:36:17 -04:00
Gregg Van Hove
7e6e905814 Merge branch 'logankd-toHaveBeenCalledTimes'
Fixes #871
2015-06-05 21:09:51 -07:00
Kevin
a6a1962924 add toHaveBeenCalledTimes matcher
Fix #853
2015-06-05 21:07:24 -07:00
Gregg Van Hove
50944fea6f Mention use of bundle exec for running the jasmine server during dev 2015-06-05 20:36:56 -07:00
Liam Wall
7bfc4c0a45 xdescribe marks pending, plus associated tests. 2015-05-29 17:21:28 +01:00
Gregg Van Hove and Noah Denton
4be2079482 Use the travis sauce connect addon 2015-05-18 17:04:21 -07:00
Gregg Van Hove
d6f47ea886 Merge pull request #856 from lpww/patch-1
Update CONTRIBUTING.md
2015-05-18 14:29:44 -07:00
Gregg Van Hove
5061dd066c Merge branch 'unique-css-classes' of https://github.com/prather-mcs/jasmine into prather-mcs-unique-css-classes 2015-05-18 14:29:03 -07:00
Gregg Van Hove
2a847a67e3 Merge branch 'danfinnie-any-vs-anything-error' 2015-05-18 14:27:27 -07:00
Thomas Treffry
50223d97d6 Update CONTRIBUTING.md
Rephrase confusing statement:

From:
If when you run ($ grunt)...you see that JSHint runs your system is ready.

To:
Now run ($ grunt)...if you see that JSHint runs, your system is ready.
2015-05-17 11:49:39 -07:00
Dan Finnie
302e78f1df Raise an error when jasmine.any() isn't passed a constructor 2015-05-17 02:21:26 -04:00
Matt Prather
42ad12ec52 Make the HtmlReport CSS classes "unique enough"
The only difference between this commit and the previous is that I have
used a difference scheme for naming Jasmine CSS classes.

Instead of appending "_jasmine-css" to all Jasmine CSS selectors, I have
now preprended "jasmine-" instead.
2015-05-14 14:23:06 -07:00
Matt Prather
c41fa7d156 Make the HtmlReport CSS classes "unique enough"
As described in Issue Report 844...
https://github.com/jasmine/jasmine/issues/844

...style rules in the app-being-tested may incidentally affect elements
in the Jasmine HTML Report container, as long as there is a chance that
the app-being-tested has CSS style rules for classes (or IDs) that
Jasmine uses.

This fix attempts to bring Jasmine to a state where each and every class
it uses always ends with "_jasmine-css" which should be unique enough to
ensure that CSS in the app-being-tested won't affect the Jasmine report,
because no app-being-tested is ever likely to use classes that end with
"_jasmine-css"

I'll be surpised if this commit is good enough as it is now, on the
first attempt to fix #844, because of reasons I'll explain in either
the Issue or the Pull Request.
2015-05-13 18:55:44 -07:00
Gregg Van Hove
0b1449228f Bump version to 2.3.4 2015-05-13 14:57:56 -07:00
Gregg Van Hove
65a6decd6d Fix ordering for suites with more than 11 direct children.
- When no specs were focused, they all had the same precedence, and
  `sort`ing them caused some of the nodes to move around

Fixes #850
2015-05-13 14:45:11 -07:00
Gregg Van Hove
7cbd86357d Merge branch 'remove-dead-css' of https://github.com/prather-mcs/jasmine into prather-mcs-remove-dead-css 2015-05-13 11:03:25 -07:00
Gregg Van Hove
4f278be2c2 Update standalone installation instructions to reference the releases page
Fix #603
2015-05-13 10:59:39 -07:00
Matt Prather
f2bc9b5bd8 Remove the style rule for .running-alert CSS class
https://github.com/jasmine/jasmine/issues/847#issuecomment-101446573
2015-05-12 15:51:42 -07:00
Gregg Van Hove
e9d79bc946 Merge branch 'prather-mcs-remove-dead-css' 2015-05-11 10:59:36 -07:00
Gregg Van Hove
f02824ae52 Merge branch 'remove-dead-css' of https://github.com/prather-mcs/jasmine into prather-mcs-remove-dead-css 2015-05-11 10:41:18 -07:00
Matt Prather
e855c898d1 Remove dead CSS class styles
I removed the `.showDetails` and `.summaryMenuItem` styles from the Sass
file because I believe that no HTML elements with those classes will
ever be generated by Jasmine and that they are dead code that someone
forgot to remove.

This is my first contribution to the Jasmine project and so I might be
doing something wrong, but I believe just this one change will propagate
to all the generated code when it is built, and that I should not be
altering any other code in any other place to accomplish the change I
intend.

This is related to Jasmine Issue 847:
https://github.com/jasmine/jasmine/issues/847
2015-05-10 16:58:07 -07:00
49 changed files with 1494 additions and 490 deletions

View File

@@ -17,11 +17,18 @@ env:
- secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo=
- secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g=
addons:
sauce_connect: true
matrix:
include:
- env:
- USE_SAUCE=false
- TEST_COMMAND="bash travis-node-script.sh"
- env:
- JASMINE_BROWSER="safari"
- SAUCE_OS="OS X 10.11"
- SAUCE_BROWSER_VERSION=9
- env:
- JASMINE_BROWSER="safari"
- SAUCE_OS="OS X 10.10"
@@ -34,10 +41,6 @@ matrix:
- JASMINE_BROWSER="safari"
- SAUCE_OS="OS X 10.8"
- SAUCE_BROWSER_VERSION=6
- env:
- JASMINE_BROWSER="safari"
- SAUCE_OS="OS X 10.6"
- SAUCE_BROWSER_VERSION=5
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_OS="Windows 8.1"

View File

@@ -1,6 +1,6 @@
# 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.
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.
## Links
@@ -82,11 +82,11 @@ To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http:/
$ npm install --local
...will install all of the node modules locally. If when you run
...will install all of the node modules locally. Now run
$ grunt
...you see that JSHint runs your system is ready.
...if you see that JSHint runs, your system is ready.
### How to write new Jasmine code
@@ -105,7 +105,7 @@ Follow these tips and your pull request, patch, or suggestion is much more likel
Jasmine uses the [Jasmine Ruby gem](http://github.com/jasmine/jasmine-gem) to test itself in browser.
$ rake jasmine
$ bundle exec rake jasmine
...and then visit `http://localhost:8888` to run specs.

View File

@@ -1,64 +0,0 @@
# (Vague) Jasmine 2.0 Goals/(Guidelines)
1. No globals!
* jasmine library is entirely inside `jasmine` namespace
* globals required for backwards compatibility should be added in `boot.js` (EG, var describe = jasmine.getCurrentEnv().describe lives in boot.js)
1. Don't use properties as getters. Use methods.
* Properties aren't encapsulated -- can be mutated, unsafe.
1. Reporters get data objects (no methods).
* easier to refactor as needed
1. More unit tests - fewer nasty integration tests
## Remaining non-story-able work:
* Make a `TODO` list
### Hard
* Finish killing Globals
* Guidelines:
* New objects can have constructors on `jasmine`
* Top level functions can live on `jasmine`
* Top level (i.e., any `jasmine` property) should only be referenced inside the `Env` constructor
* should better allow any object to get jasmine code (Node-friendly)
* review everything in base.js
* Remove isA functions:
* isArray_ - used in matchers and spies
* isString_
* isDOMNode_
* isA_
* unimplementedMethod_, used by PrettyPrinter
* jasmine.util should be util closure inside of env or something
* argsToArray is used for Spies and matching (and can be replaced)
* inherit is only for PrettyPrinter now
* formatException is used only inside Env/spec
* htmlEscape is for messages in matchers - should this be HTML at all?
* Pretty printing
* move away from pretty printer and to a JSON.stringify implementation?
* jasmineToString vs. custom toString ?
### Easy
* unify params to ctors: options vs. attrs.
* This will be a lot of the TODOs, but clean up & simplify Env.js (is this a 2.1 task?)
### DONE
* Matchers improvements
* unit testable DONE
* better equality (from Underscore) DONE
* addCustomMatchers doesn't explode stack DONE
* refactor equals function so that it just loops & recurses over a list of fns (custom and built-in) - 2.1? (Tracker story)
* Spies
* break these out into their own tests/file DONE
## Other Topics
* Docs
* Docco has gone over well. Should we annotate all the sources and then have Pages be more complex, having tutorials and annotated source like Backbone? Are we small enough?
* Need examples for:
* How to build a Custom Matcher
* How to add a custom equality tester

View File

@@ -1,6 +1,7 @@
<a name="README">[<img src="https://rawgithub.com/jasmine/jasmine/master/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
[![Build Status](https://travis-ci.org/jasmine/jasmine.png?branch=master)](https://travis-ci.org/jasmine/jasmine) [![Code Climate](https://codeclimate.com/github/pivotal/jasmine.png)](https://codeclimate.com/github/pivotal/jasmine)
[![Build Status](https://travis-ci.org/jasmine/jasmine.svg?branch=master)](https://travis-ci.org/jasmine/jasmine)
[![Code Climate](https://codeclimate.com/github/pivotal/jasmine.svg)](https://codeclimate.com/github/pivotal/jasmine)
=======
@@ -28,22 +29,24 @@ For the Jasmine Ruby Gem:<br>
For the Jasmine Python Egg:<br>
[https://github.com/jasmine/jasmine-py](https://github.com/jasmine/jasmine-py)
To install Jasmine on your local box:
To install Jasmine standalone on your local box:
* Clone Jasmine - `git clone https://github.com/jasmine/jasmine.git`
* Download the standalone distribution for your desired release from the [releases page](https://github.com/jasmine/jasmine/releases)
* Create a Jasmine directory in your project - `mkdir my-project/jasmine`
* Move latest dist to your project directory - `mv jasmine/dist/jasmine-standalone-2.0.0.zip my-project/jasmine`
* Move the dist to your project directory - `mv jasmine/dist/jasmine-standalone-2.0.0.zip my-project/jasmine`
* Change directory - `cd my-project/jasmine`
* Unzip the dist - `unzip jasmine-standalone-2.0.0.zip`
Add the following to your HTML file:
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-2.0.0/jasmine.css">
```html
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-2.0.0/jasmine.css">
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/boot.js"></script>
```
## Supported environments
@@ -62,6 +65,8 @@ Jasmine tests itself across many browsers (Safari, Chrome, Firefox, PhantomJS, a
* [Davis W. Frank](mailto:dwfrank@pivotal.io), Pivotal Labs
* [Rajan Agaskar](mailto:rajan@pivotal.io), Pivotal Labs
* [Gregg Van Hove](mailto:gvanhove@pivotal.io), Pivotal Labs
* [Greg Cobb](mailto:gcobb@pivotal.io), Pivotal Labs
* [Chris Amavisca](mailto:camavisca@pivotal.io), Pivotal Labs
### Maintainers Emeritus

View File

@@ -15,7 +15,7 @@ Please attempt to keep commits to `master` small, but cohesive. If a feature is
We attempt to stick to [Semantic Versioning](http://semver.org/). Most of the time, development should be against a new minor version - fixing bugs and adding new features that are backwards compatible.
The current version lives in the file `/package.json`. This version will be the version number that is currently released. When releasing a new version, update `package.json` and `bower.json` with the new version and `grunt build:copyVersionToGem` to update the gem version number.
The current version lives in the file `/package.json`. This version will be the version number that is currently released. When releasing a new version, update `package.json` with the new version and `grunt build:copyVersionToGem` to update the gem version number.
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.

View File

@@ -1,6 +1,5 @@
{
"name": "jasmine-core",
"version": "2.3.3",
"homepage": "http://jasmine.github.io",
"authors": [
"slackersoft <gregg@slackersoft.net>"

View File

@@ -26,6 +26,7 @@ module.exports = {
'src/core/base.js',
'src/core/util.js',
'src/core/Spec.js',
'src/core/Order.js',
'src/core/Env.js',
'src/core/JsApiReporter.js',
'src/core/PrettyPrinter',

View File

@@ -77,6 +77,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var throwingExpectationFailures = queryString.getParam("throwFailures");
env.throwOnExpectationFailure(throwingExpectationFailures);
var random = queryString.getParam("random");
env.randomizeTests(random);
var seed = queryString.getParam("seed");
if (seed) {
env.seed(seed);
}
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
@@ -85,6 +93,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
env: env,
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },

View File

@@ -55,6 +55,14 @@
var throwingExpectationFailures = queryString.getParam("throwFailures");
env.throwOnExpectationFailure(throwingExpectationFailures);
var random = queryString.getParam("random");
env.randomizeTests(random);
var seed = queryString.getParam("seed");
if (seed) {
env.seed(seed);
}
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
@@ -63,6 +71,7 @@
env: env,
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },

View File

@@ -41,6 +41,7 @@ jasmineRequire.HtmlReporter = function(j$) {
createTextNode = options.createTextNode,
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
onRandomClick = options.onRandomClick || function() {},
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
timer = options.timer || noopTimer,
results = [],
@@ -54,19 +55,17 @@ jasmineRequire.HtmlReporter = function(j$) {
this.initialize = function() {
clearPrior();
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
createDom('div', {className: 'banner'},
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'version'}, j$.version)
createDom('div', {className: 'jasmine-banner'},
createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'jasmine-version'}, j$.version)
),
createDom('ul', {className: 'symbol-summary'}),
createDom('div', {className: 'alert'}),
createDom('div', {className: 'results'},
createDom('div', {className: 'failures'})
createDom('ul', {className: 'jasmine-symbol-summary'}),
createDom('div', {className: 'jasmine-alert'}),
createDom('div', {className: 'jasmine-results'},
createDom('div', {className: 'jasmine-failures'})
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find('.symbol-summary');
};
var totalSpecsDefined;
@@ -75,7 +74,7 @@ jasmineRequire.HtmlReporter = function(j$) {
timer.start();
};
var summary = createDom('div', {className: 'summary'});
var summary = createDom('div', {className: 'jasmine-summary'});
var topResults = new j$.ResultsNode({}, '', null),
currentParent = topResults;
@@ -111,8 +110,12 @@ jasmineRequire.HtmlReporter = function(j$) {
specsExecuted++;
}
if (!symbols){
symbols = find('.jasmine-symbol-summary');
}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'empty' : result.status,
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
id: 'spec_' + result.id,
title: result.fullName
}
@@ -122,18 +125,18 @@ jasmineRequire.HtmlReporter = function(j$) {
failureCount++;
var failure =
createDom('div', {className: 'spec-detail failed'},
createDom('div', {className: 'description'},
createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
createDom('div', {className: 'jasmine-description'},
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
),
createDom('div', {className: 'messages'})
createDom('div', {className: 'jasmine-messages'})
);
var messages = failure.childNodes[1];
for (var i = 0; i < result.failedExpectations.length; i++) {
var expectation = result.failedExpectations[i];
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
}
failures.push(failure);
@@ -144,86 +147,106 @@ jasmineRequire.HtmlReporter = function(j$) {
}
};
this.jasmineDone = function() {
var banner = find('.banner');
var alert = find('.alert');
alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
this.jasmineDone = function(doneResult) {
var banner = find('.jasmine-banner');
var alert = find('.jasmine-alert');
var order = doneResult && doneResult.order;
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
banner.appendChild(
createDom('div', { className: 'run-options' },
createDom('span', { className: 'trigger' }, 'Options'),
createDom('div', { className: 'payload' },
createDom('div', { className: 'exceptions' },
createDom('div', { className: 'jasmine-run-options' },
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
createDom('div', { className: 'jasmine-payload' },
createDom('div', { className: 'jasmine-exceptions' },
createDom('input', {
className: 'raise',
id: 'raise-exceptions',
className: 'jasmine-raise',
id: 'jasmine-raise-exceptions',
type: 'checkbox'
}),
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')),
createDom('div', { className: 'throw-failures' },
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-raise-exceptions' }, 'raise exceptions')),
createDom('div', { className: 'jasmine-throw-failures' },
createDom('input', {
className: 'throw',
id: 'throw-failures',
className: 'jasmine-throw',
id: 'jasmine-throw-failures',
type: 'checkbox'
}),
createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure'))
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
createDom('div', { className: 'jasmine-random-order' },
createDom('input', {
className: 'jasmine-random',
id: 'jasmine-random-order',
type: 'checkbox'
}),
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
)
));
var raiseCheckbox = find('#raise-exceptions');
var raiseCheckbox = find('#jasmine-raise-exceptions');
raiseCheckbox.checked = !env.catchingExceptions();
raiseCheckbox.onclick = onRaiseExceptionsClick;
var throwCheckbox = find('#throw-failures');
var throwCheckbox = find('#jasmine-throw-failures');
throwCheckbox.checked = env.throwingExpectationFailures();
throwCheckbox.onclick = onThrowExpectationsClick;
var optionsMenu = find('.run-options'),
optionsTrigger = optionsMenu.querySelector('.trigger'),
optionsPayload = optionsMenu.querySelector('.payload'),
isOpen = /\bopen\b/;
var randomCheckbox = find('#jasmine-random-order');
randomCheckbox.checked = env.randomTests();
randomCheckbox.onclick = onRandomClick;
var optionsMenu = find('.jasmine-run-options'),
optionsTrigger = optionsMenu.querySelector('.jasmine-trigger'),
optionsPayload = optionsMenu.querySelector('.jasmine-payload'),
isOpen = /\bjasmine-open\b/;
optionsTrigger.onclick = function() {
if (isOpen.test(optionsPayload.className)) {
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
} else {
optionsPayload.className += ' open';
optionsPayload.className += ' jasmine-open';
}
};
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
alert.appendChild(
createDom('span', {className: 'bar skipped'},
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
)
);
}
var statusBarMessage = '';
var statusBarClassName = 'bar ';
var statusBarClassName = 'jasmine-bar ';
if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
statusBarClassName += (failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
} else {
statusBarClassName += 'skipped';
statusBarClassName += 'jasmine-skipped';
statusBarMessage += 'No specs found';
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
var seedBar;
if (order && order.random) {
seedBar = createDom('span', {className: 'jasmine-seed-bar'},
', randomized with seed ',
createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
);
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
for(i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
var errorBarClassName = 'bar errored';
var errorBarClassName = 'jasmine-bar jasmine-errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}
}
var results = find('.results');
var results = find('.jasmine-results');
results.appendChild(summary);
summaryList(topResults, summary);
@@ -233,8 +256,8 @@ jasmineRequire.HtmlReporter = function(j$) {
for (var i = 0; i < resultsTree.children.length; i++) {
var resultNode = resultsTree.children[i];
if (resultNode.type == 'suite') {
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'suite-detail'},
var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'jasmine-suite-detail'},
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
)
);
@@ -243,8 +266,8 @@ jasmineRequire.HtmlReporter = function(j$) {
domParent.appendChild(suiteListNode);
}
if (resultNode.type == 'spec') {
if (domParent.getAttribute('class') != 'specs') {
specListNode = createDom('ul', {className: 'specs'});
if (domParent.getAttribute('class') != 'jasmine-specs') {
specListNode = createDom('ul', {className: 'jasmine-specs'});
domParent.appendChild(specListNode);
}
var specDescription = resultNode.result.description;
@@ -256,7 +279,7 @@ jasmineRequire.HtmlReporter = function(j$) {
}
specListNode.appendChild(
createDom('li', {
className: resultNode.result.status,
className: 'jasmine-' + resultNode.result.status,
id: 'spec-' + resultNode.result.id
},
createDom('a', {href: specHref(resultNode.result)}, specDescription)
@@ -268,24 +291,24 @@ jasmineRequire.HtmlReporter = function(j$) {
if (failures.length) {
alert.appendChild(
createDom('span', {className: 'menu bar spec-list'},
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
createDom('span', {}, 'Spec List | '),
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
alert.appendChild(
createDom('span', {className: 'menu bar failure-list'},
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {}, ' | Failures ')));
find('.failures-menu').onclick = function() {
setMenuModeTo('failure-list');
find('.jasmine-failures-menu').onclick = function() {
setMenuModeTo('jasmine-failure-list');
};
find('.spec-list-menu').onclick = function() {
setMenuModeTo('spec-list');
find('.jasmine-spec-list-menu').onclick = function() {
setMenuModeTo('jasmine-spec-list');
};
setMenuModeTo('failure-list');
setMenuModeTo('jasmine-failure-list');
var failureNode = find('.failures');
var failureNode = find('.jasmine-failures');
for (var i = 0; i < failures.length; i++) {
failureNode.appendChild(failures[i]);
}
@@ -343,6 +366,10 @@ jasmineRequire.HtmlReporter = function(j$) {
return addToExistingQueryString('spec', result.fullName);
}
function seedHref(seed) {
return addToExistingQueryString('seed', seed);
}
function defaultQueryString(key, value) {
return '?' + key + '=' + value;
}

File diff suppressed because one or more lines are too long

View File

@@ -24,7 +24,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
var jasmineRequire;
if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
if (typeof global !== 'undefined') {
jasmineGlobal = global;
} else {
jasmineGlobal = {};
}
jasmineRequire = exports;
} else {
if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
@@ -68,6 +72,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.Timer = jRequire.Timer();
j$.TreeProcessor = jRequire.TreeProcessor();
j$.version = jRequire.version();
j$.Order = jRequire.Order();
j$.matchers = jRequire.requireMatchers(jRequire, j$);
@@ -93,6 +98,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
'toEqual',
'toHaveBeenCalled',
'toHaveBeenCalledWith',
'toHaveBeenCalledTimes',
'toMatch',
'toThrow',
'toThrowError'
@@ -447,6 +453,53 @@ if (typeof window == void 0 && typeof exports == 'object') {
exports.Spec = jasmineRequire.Spec;
}
/*jshint bitwise: false*/
getJasmineRequireObj().Order = function() {
function Order(options) {
this.random = 'random' in options ? options.random : true;
var seed = this.seed = options.seed || generateSeed();
this.sort = this.random ? randomOrder : naturalOrder;
function naturalOrder(items) {
return items;
}
function randomOrder(items) {
var copy = items.slice();
copy.sort(function(a, b) {
return jenkinsHash(seed + a.id) - jenkinsHash(seed + b.id);
});
return copy;
}
function generateSeed() {
return String(Math.random()).slice(-5);
}
// Bob Jenkins One-at-a-Time Hash algorithm is a non-cryptographic hash function
// used to get a different output when the key changes slighly.
// We use your return to sort the children randomly in a consistent way when
// used in conjunction with a seed
function jenkinsHash(key) {
var hash, i;
for(hash = i = 0; i < key.length; ++i) {
hash += key.charCodeAt(i);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
}
return Order;
};
getJasmineRequireObj().Env = function(j$) {
function Env(options) {
options = options || {};
@@ -469,6 +522,8 @@ getJasmineRequireObj().Env = function(j$) {
var currentlyExecutingSuites = [];
var currentDeclarationSuite = null;
var throwOnExpectationFailure = false;
var random = false;
var seed = null;
var currentSuite = function() {
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
@@ -618,6 +673,21 @@ getJasmineRequireObj().Env = function(j$) {
return throwOnExpectationFailure;
};
this.randomizeTests = function(value) {
random = !!value;
};
this.randomTests = function() {
return random;
};
this.seed = function(value) {
if (value) {
seed = value;
}
return seed;
};
var queueRunnerFactory = function(options) {
options.catchException = catchException;
options.clearStack = options.clearStack || clearStack;
@@ -649,6 +719,12 @@ getJasmineRequireObj().Env = function(j$) {
runnablesToRun = [topSuite.id];
}
}
var order = new j$.Order({
random: random,
seed: seed
});
var processor = new j$.TreeProcessor({
tree: topSuite,
runnableIds: runnablesToRun,
@@ -664,6 +740,9 @@ getJasmineRequireObj().Env = function(j$) {
}
currentlyExecutingSuites.pop();
reporter.suiteDone(result);
},
orderChildren: function(node) {
return order.sort(node.children);
}
});
@@ -675,7 +754,11 @@ getJasmineRequireObj().Env = function(j$) {
totalSpecsDefined: totalSpecsDefined
});
processor.execute(reporter.jasmineDone);
processor.execute(function() {
reporter.jasmineDone({
order: order
});
});
};
this.addReporter = function(reporterToAdd) {
@@ -710,13 +793,20 @@ getJasmineRequireObj().Env = function(j$) {
this.describe = function(description, specDefinitions) {
var suite = suiteFactory(description);
if (specDefinitions.length > 0) {
throw new Error('describe does not expect a done parameter');
}
if (currentDeclarationSuite.markedPending) {
suite.pend();
}
addSpecsToSuite(suite, specDefinitions);
return suite;
};
this.xdescribe = function(description, specDefinitions) {
var suite = this.describe(description, specDefinitions);
suite.disable();
var suite = suiteFactory(description);
suite.pend();
addSpecsToSuite(suite, specDefinitions);
return suite;
};
@@ -822,19 +912,22 @@ getJasmineRequireObj().Env = function(j$) {
this.it = function(description, fn, timeout) {
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
if (currentDeclarationSuite.markedPending) {
spec.pend();
}
currentDeclarationSuite.addChild(spec);
return spec;
};
this.xit = function() {
var spec = this.it.apply(this, arguments);
spec.pend();
spec.pend('Temporarily disabled with xit');
return spec;
};
this.fit = function(){
var spec = this.it.apply(this, arguments);
this.fit = function(description, fn, timeout){
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
unfocusAncestor();
return spec;
@@ -918,6 +1011,7 @@ getJasmineRequireObj().JsApiReporter = function() {
this.started = false;
this.finished = false;
this.runDetails = {};
this.jasmineStarted = function() {
this.started = true;
@@ -927,8 +1021,9 @@ getJasmineRequireObj().JsApiReporter = function() {
var executionTime;
this.jasmineDone = function() {
this.jasmineDone = function(runDetails) {
this.finished = true;
this.runDetails = runDetails;
executionTime = timer.elapsed();
status = 'done';
};
@@ -1606,6 +1701,8 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('HTMLNode');
} else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')');
} else if (value.toString && typeof value === 'object' && !(value instanceof Array) && value.toString !== Object.prototype.toString) {
this.emitScalar(value.toString());
} else if (j$.util.arrayContains(this.seen, value)) {
this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {
@@ -1810,7 +1907,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
if (queueableFn.timeout) {
timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() {
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
onException(error, queueableFn);
onException(error);
next();
}, queueableFn.timeout()]]);
}
@@ -1823,12 +1920,12 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
}
function onException(e, queueableFn) {
function onException(e) {
self.onException(e);
}
function handleException(e, queueableFn) {
onException(e, queueableFn);
onException(e);
if (!self.catchException(e)) {
//TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
@@ -1900,6 +1997,17 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error(methodName + ' has already been spied upon');
}
var descriptor;
try {
descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
} catch(e) {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}
if (descriptor && !(descriptor.writable || descriptor.set)) {
throw new Error(methodName + ' is not declared writable or has no setter');
}
var spy = j$.createSpy(methodName, obj[methodName]);
currentSpies().push({
@@ -2030,6 +2138,10 @@ getJasmineRequireObj().Suite = function(j$) {
this.disabled = true;
};
Suite.prototype.pend = function(message) {
this.markedPending = true;
};
Suite.prototype.beforeEach = function(fn) {
this.beforeFns.unshift(fn);
};
@@ -2055,6 +2167,10 @@ getJasmineRequireObj().Suite = function(j$) {
return 'disabled';
}
if (this.markedPending) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
@@ -2184,6 +2300,7 @@ getJasmineRequireObj().TreeProcessor = function() {
queueRunnerFactory = attrs.queueRunnerFactory,
nodeStart = attrs.nodeStart || function() {},
nodeComplete = attrs.nodeComplete || function() {},
orderChildren = attrs.orderChildren || function(node) { return node.children; },
stats = { valid: true },
processed = false,
defaultMin = Infinity,
@@ -2247,8 +2364,10 @@ getJasmineRequireObj().TreeProcessor = function() {
} else {
var hasExecutableChild = false;
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
var orderedChildren = orderChildren(node);
for (var i = 0; i < orderedChildren.length; i++) {
var child = orderedChildren[i];
processNode(child, parentEnabled);
@@ -2265,7 +2384,7 @@ getJasmineRequireObj().TreeProcessor = function() {
executable: hasExecutableChild
};
segmentChildren(node, stats[node.id], executableIndex);
segmentChildren(node, orderedChildren, stats[node.id], executableIndex);
if (!node.canBeReentered() && stats[node.id].segments.length > 1) {
stats = { valid: false };
@@ -2281,11 +2400,11 @@ getJasmineRequireObj().TreeProcessor = function() {
return executableIndex === undefined ? defaultMax : executableIndex;
}
function segmentChildren(node, nodeStats, executableIndex) {
function segmentChildren(node, orderedChildren, nodeStats, executableIndex) {
var currentSegment = { index: 0, owner: node, nodes: [], min: startingMin(executableIndex), max: startingMax(executableIndex) },
result = [currentSegment],
lastMax = defaultMax,
orderedChildSegments = orderChildSegments(node.children);
orderedChildSegments = orderChildSegments(orderedChildren);
function isSegmentBoundary(minIndex) {
return lastMax !== defaultMax && minIndex !== defaultMin && lastMax < minIndex - 1;
@@ -2311,30 +2430,29 @@ getJasmineRequireObj().TreeProcessor = function() {
}
function orderChildSegments(children) {
var result = [];
var specifiedOrder = [],
unspecifiedOrder = [];
for (var i = 0; i < children.length; i++) {
var child = children[i],
segments = stats[child.id].segments;
for (var j = 0; j < segments.length; j++) {
result.push(segments[j]);
var seg = segments[j];
if (seg.min === defaultMin) {
unspecifiedOrder.push(seg);
} else {
specifiedOrder.push(seg);
}
}
}
result.sort(function(a, b) {
if (a.min === null) {
return b.min === null ? 0 : 1;
}
if (b.min === null) {
return -1;
}
specifiedOrder.sort(function(a, b) {
return a.min - b.min;
});
return result;
return specifiedOrder.concat(unspecifiedOrder);
}
function executeNode(node, segmentNumber) {
@@ -2385,6 +2503,12 @@ getJasmineRequireObj().TreeProcessor = function() {
getJasmineRequireObj().Any = function(j$) {
function Any(expectedObject) {
if (typeof expectedObject === 'undefined') {
throw new TypeError(
'jasmine.any() expects to be passed a constructor function. ' +
'Please pass one or use jasmine.anything() to match any object.'
);
}
this.expectedObject = expectedObject;
}
@@ -2977,6 +3101,37 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
return toHaveBeenCalled;
};
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
function toHaveBeenCalledTimes() {
return {
compare: function(actual, expected) {
if (!j$.isSpy(actual)) {
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
}
var args = Array.prototype.slice.call(arguments, 0),
result = { pass: false };
if(!expected){
throw new Error('Expected times failed is required as an argument.');
}
actual = args[0];
var calls = actual.calls.count();
var timesMessage = expected === 1 ? 'once' : expected + ' times';
result.pass = calls === expected;
result.message = result.pass ?
'Expected spy ' + actual.and.identity() + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
'Expected spy ' + actual.and.identity() + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
return result;
}
};
}
return toHaveBeenCalledTimes;
};
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
function toHaveBeenCalledWith(util, customEqualityTesters) {
@@ -3080,7 +3235,7 @@ getJasmineRequireObj().toThrow = function(j$) {
};
getJasmineRequireObj().toThrowError = function(j$) {
function toThrowError (util) {
function toThrowError () {
return {
compare: function(actual) {
var threw = false,
@@ -3295,5 +3450,5 @@ getJasmineRequireObj().interface = function(jasmine, env) {
};
getJasmineRequireObj().version = function() {
return '2.3.3';
return '2.4.1';
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "2.3.3"
VERSION = "2.4.1"
end
end

View File

@@ -1,7 +1,7 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "2.3.3",
"version": "2.4.1",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
@@ -19,14 +19,14 @@
"homepage": "http://jasmine.github.io",
"main": "./lib/jasmine-core.js",
"devDependencies": {
"glob": "~3.2.9",
"glob": "~5.0.13",
"grunt": "~0.4.1",
"grunt-cli": "^0.1.13",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-compress": "~0.5.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-jshint": "~0.7.0",
"jasmine": "https://github.com/jasmine/jasmine-npm/archive/master.tar.gz",
"jasmine": "git://github.com/jasmine/jasmine-npm.git",
"load-grunt-tasks": "^0.4.0",
"shelljs": "~0.1.4",
"temp": "~0.8.1"

22
release_notes/2.3.4.md Normal file
View File

@@ -0,0 +1,22 @@
# Jasmine 2.3.4 Release Notes
## Summary
This is a hotfix release to fix a regression with execution ordering
## Pull Requests & Issues
* Fix ordering for suites with more than 11 direct children.
- Fixes [#850](https://github.com/jasmine/jasmine/issues/850)
* Update standalone installation instructions to reference the releases page
- Fixes [#603](https://github.com/jasmine/jasmine/issues/603)
* Remove dead CSS class styles
- Merges [#849](https://github.com/jasmine/jasmine/issues/849) from @prather-mcs
- Merges [#848](https://github.com/jasmine/jasmine/issues/848) from @prather-mcs
- Fixes [#847](https://github.com/jasmine/jasmine/issues/847)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

91
release_notes/2.4.0.md Normal file
View File

@@ -0,0 +1,91 @@
# Jasmine Core 2.4.0 Release Notes
## Summary
This release contains a number of fixes and pull requests.
The most notable is probably that Jasmine now supports randomization of spec order
## Changes
* Run jasmine's specs in random order
* Add support for returning run details for reporting randomness
* Use className instead of class when creating DOM elements
## Pull Requests & Issues
* Syntax highlighting in README.md
- Merges [#973](https://github.com/jasmine/jasmine/issues/973) from @brunoqc
* Added a throw error block in describe incase a function with arguments is passed in describe
- Fixes [#896](https://github.com/jasmine/jasmine/issues/896)
- Merges [#955](https://github.com/jasmine/jasmine/issues/955) from @himajasuman
* Remove unused `queueableFn` arg from `onException`
- Fixes [#958](https://github.com/jasmine/jasmine/issues/958)
* Remove unused parameter from toThrowError
- Merges [#957](https://github.com/jasmine/jasmine/issues/957) from @FuzzySockets
* Abort spying when the target cannot be spied upon
- Fixes [#948](https://github.com/jasmine/jasmine/issues/948)
- Merges [#949](https://github.com/jasmine/jasmine/issues/949) from @StephanBijzitter
* Removed GOALS_2.0.md, doesn't seem to be needed anymore
- Merges [#954](https://github.com/jasmine/jasmine/issues/954) from @matthewhuff89
* Change #xit so that it will output a more BDD-style pending message
- Merges [#942](https://github.com/jasmine/jasmine/issues/942) from @lalunamel
- Fixes [#930](https://github.com/jasmine/jasmine/issues/930)
- Fixes [#912](https://github.com/jasmine/jasmine/issues/912)
* Allow tests to run in random order
- Merges [#927](https://github.com/jasmine/jasmine/issues/927) from @marcioj
* Use toString for objects if it has been overriden
- Merges [#929](https://github.com/jasmine/jasmine/issues/929) from @myitcv
- Fixes [#928](https://github.com/jasmine/jasmine/issues/928)
* Fix circles/x from getting cut off on Mac/chrome
- Merges [#932](https://github.com/jasmine/jasmine/issues/932) from @James-Dunn
* Postpone find() until it is needed
- Merges [#924](https://github.com/jasmine/jasmine/issues/924) from @danielalexiuc
- Fixes [#917](https://github.com/jasmine/jasmine/issues/917)
* check for global before assigning
* Reverse suite afterEach behavior to match semantics?
- Merges [#908](https://github.com/jasmine/jasmine/issues/908) from @mcamac
* Use badges from shields.io
- Merges [#902](https://github.com/jasmine/jasmine/issues/902) from @SimenB
* xdescribe marks pending, plus associated tests.
- Merges [#869](https://github.com/jasmine/jasmine/issues/869) from @ljwall
- Fixes [#855](https://github.com/jasmine/jasmine/issues/855)
* Update glob to latest
- Merge [#892](https://github.com/jasmine/jasmine/issues/892) from @obastemur
- Fixes [#891](https://github.com/jasmine/jasmine/issues/891)
* Remove moot `version` property from bower.json
- Merges [#874](https://github.com/jasmine/jasmine/issues/874) from @kkirsche
* add toHaveBeenCalledTimes matcher
- Merges [#871](https://github.com/jasmine/jasmine/issues/871) from @logankd
- Fixes [#853](https://github.com/jasmine/jasmine/issues/853)
* Update CONTRIBUTING.md
- Merges [#856](https://github.com/jasmine/jasmine/issues/856) from @lpww
* Make the HtmlReport CSS classes "unique enough"
- Merges [#851](https://github.com/jasmine/jasmine/issues/851) from @prather-mcs
- Fixes [#844](https://github.com/jasmine/jasmine/issues/844)
* Raise an error when jasmine.any() isn't passed a constructor
- Merges [#854](https://github.com/jasmine/jasmine/issues/854) from @danfinnie
- Fixes [#852](https://github.com/jasmine/jasmine/issues/852)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

11
release_notes/2.4.1.md Normal file
View File

@@ -0,0 +1,11 @@
# Jasmine Core 2.4.1 Release Notes
## Changes
* Run `afterEach` in reverse order declared as before
- Reverts [#908](https://github.com/jasmine/jasmine/issues/908)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -26,6 +26,15 @@ describe("Env", function() {
});
});
describe('#describe', function () {
var spec = function(done){};
it("throws the error", function() {
expect(function() {
env.describe('done method', spec);
}).toThrow(new Error('describe does not expect a done parameter'));
});
});
it('can configure specs to throw errors on expectation failures', function() {
env.throwOnExpectationFailure(true);
@@ -45,4 +54,15 @@ describe("Env", function() {
throwOnExpectationFailure: true
}));
});
describe('#xit', function() {
it('calls spec.pend with "Temporarily disabled with xit"', function() {
var pendSpy = jasmine.createSpy();
spyOn(env, 'it').and.returnValue({
pend: pendSpy
});
env.xit();
expect(pendSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
});
});
});

View File

@@ -248,4 +248,12 @@ describe("JsApiReporter", function() {
});
});
});
describe('#runDetails', function() {
it('should have details about the run', function() {
var reporter = new j$.JsApiReporter({});
reporter.jasmineDone({some: {run: 'details'}});
expect(reporter.runDetails).toEqual({some: {run: 'details'}});
});
});
});

View File

@@ -181,6 +181,14 @@ describe("j$.pp", function () {
expect(j$.pp(obj)).toEqual("strung");
});
it("should stringify objects that implement custom toString", function () {
var obj = {
toString: function () { return "my toString"; }
};
expect(j$.pp(obj)).toEqual("my toString");
});
it("should handle objects with null prototype", function() {
if (jasmine.getEnv().ieVersion < 9) { return; }

View File

@@ -37,6 +37,35 @@ describe("SpyRegistry", function() {
}).toThrowError(/has already been spied upon/);
});
it("checks if it can be spied upon", function() {
// IE 8 doesn't support `definePropery` on non-DOM nodes
if (jasmine.getEnv().ieVersion < 9) { return; }
var scope = {};
function myFunc() {
return 1;
}
Object.defineProperty(scope, 'myFunc', {
get: function() {
return myFunc;
}
});
var spies = [],
spyRegistry = new j$.SpyRegistry({currentSpies: function() { return spies; }}),
subject = { spiedFunc: scope.myFunc };
expect(function() {
spyRegistry.spyOn(scope, 'myFunc');
}).toThrowError(/is not declared writable or has no setter/);
expect(function() {
spyRegistry.spyOn(subject, 'spiedFunc');
}).not.toThrowError(/is not declared writable or has no setter/);
});
it("overrides the method on the object and returns the spy", function() {
var originalFunctionWasCalled = false,
spyRegistry = new j$.SpyRegistry(),

View File

@@ -90,6 +90,21 @@ describe("Suite", function() {
expect(suite.getResult().status).toBe('disabled');
});
it("retrieves a result with pending status", function() {
var suite = new j$.Suite({});
suite.pend();
expect(suite.getResult().status).toBe('pending');
});
it("priviledges a disabled status over pending status", function() {
var suite = new j$.Suite({});
suite.disable();
suite.pend();
expect(suite.getResult().status).toBe('disabled');
});
it("is executable if not disabled", function() {
var suite = new j$.Suite({});

View File

@@ -632,4 +632,125 @@ describe("TreeProcessor", function() {
childFns[1].fn();
expect(leaf3.execute).toHaveBeenCalled();
});
it("runs large segments of nodes in the order they were declared", function() {
var leaf1 = new Leaf(),
leaf2 = new Leaf(),
leaf3 = new Leaf(),
leaf4 = new Leaf(),
leaf5 = new Leaf(),
leaf6 = new Leaf(),
leaf7 = new Leaf(),
leaf8 = new Leaf(),
leaf9 = new Leaf(),
leaf10 = new Leaf(),
leaf11 = new Leaf(),
root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
queueRunner = jasmine.createSpy('queueRunner'),
processor = new j$.TreeProcessor({
tree: root,
runnableIds: [root.id],
queueRunnerFactory: queueRunner
});
processor.execute();
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
expect(queueableFns.length).toBe(11);
queueableFns[0].fn();
expect(leaf1.execute).toHaveBeenCalled();
queueableFns[1].fn();
expect(leaf2.execute).toHaveBeenCalled();
queueableFns[2].fn();
expect(leaf3.execute).toHaveBeenCalled();
queueableFns[3].fn();
expect(leaf4.execute).toHaveBeenCalled();
queueableFns[4].fn();
expect(leaf5.execute).toHaveBeenCalled();
queueableFns[5].fn();
expect(leaf6.execute).toHaveBeenCalled();
queueableFns[6].fn();
expect(leaf7.execute).toHaveBeenCalled();
queueableFns[7].fn();
expect(leaf8.execute).toHaveBeenCalled();
queueableFns[8].fn();
expect(leaf9.execute).toHaveBeenCalled();
queueableFns[9].fn();
expect(leaf10.execute).toHaveBeenCalled();
queueableFns[10].fn();
expect(leaf11.execute).toHaveBeenCalled();
});
it("runs nodes in a custom order when orderChildren is overrided", function() {
var leaf1 = new Leaf(),
leaf2 = new Leaf(),
leaf3 = new Leaf(),
leaf4 = new Leaf(),
leaf5 = new Leaf(),
leaf6 = new Leaf(),
leaf7 = new Leaf(),
leaf8 = new Leaf(),
leaf9 = new Leaf(),
leaf10 = new Leaf(),
leaf11 = new Leaf(),
root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
queueRunner = jasmine.createSpy('queueRunner'),
processor = new j$.TreeProcessor({
tree: root,
runnableIds: [root.id],
queueRunnerFactory: queueRunner,
orderChildren: function(node) {
var children = node.children.slice();
return children.reverse();
}
});
processor.execute();
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
expect(queueableFns.length).toBe(11);
queueableFns[0].fn();
expect(leaf11.execute).toHaveBeenCalled();
queueableFns[1].fn();
expect(leaf10.execute).toHaveBeenCalled();
queueableFns[2].fn();
expect(leaf9.execute).toHaveBeenCalled();
queueableFns[3].fn();
expect(leaf8.execute).toHaveBeenCalled();
queueableFns[4].fn();
expect(leaf7.execute).toHaveBeenCalled();
queueableFns[5].fn();
expect(leaf6.execute).toHaveBeenCalled();
queueableFns[6].fn();
expect(leaf5.execute).toHaveBeenCalled();
queueableFns[7].fn();
expect(leaf4.execute).toHaveBeenCalled();
queueableFns[8].fn();
expect(leaf3.execute).toHaveBeenCalled();
queueableFns[9].fn();
expect(leaf2.execute).toHaveBeenCalled();
queueableFns[10].fn();
expect(leaf1.execute).toHaveBeenCalled();
});
});

View File

@@ -42,4 +42,11 @@ describe("Any", function() {
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
});
describe("when called without an argument", function() {
it("tells the user to pass a constructor or use jasmine.anything()", function() {
expect(function() {
new j$.Any();
}).toThrowError(TypeError, /constructor.*anything/);
});
});
});

View File

@@ -207,7 +207,6 @@ describe("Env integration", function() {
var env = new j$.Env();
env.addReporter({jasmineDone: done});
env.describe("tests", function() {
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
@@ -1115,6 +1114,78 @@ describe("Env integration", function() {
env.execute();
});
it('should run focused tests inside an xdescribe', function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
description: 'with a fit spec',
status: 'failed'
}));
done();
});
env.addReporter(reporter);
env.xdescribe("xd suite", function() {
env.fit("with a fit spec", function() {
env.expect(true).toBe(false);
});
});
env.execute();
});
it('should run focused suites inside an xdescribe', function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
description: 'with a spec',
status: 'failed'
}));
done();
});
env.addReporter(reporter);
env.xdescribe("xd suite", function() {
env.fdescribe("fd suite", function() {
env.it("with a spec", function() {
env.expect(true).toBe(false);
});
});
});
env.execute();
});
});
it("should report as expected", function(done) {
@@ -1227,9 +1298,10 @@ describe("Env integration", function() {
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));
expect(reporter.suiteDone.calls.count()).toBe(3);
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' }));
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' }));
expect(reporter.suiteDone.calls.count()).toBe(4);
done();
});
@@ -1238,8 +1310,10 @@ describe("Env integration", function() {
env.describe("A Suite", function() {
env.describe("nested", function() {
env.xdescribe("xd out", function() {
env.it("with a spec", function() {
env.expect(true).toBe(false);
env.describe("nested again", function() {
env.it("with a spec", function() {
env.expect(true).toBe(false);
});
});
});
});

View File

@@ -169,7 +169,7 @@ describe("jasmine spec running", function () {
env.execute();
});
it("should run multiple befores and afters in the order they are declared", function(done) {
it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
var actions = [];
env.beforeEach(function () {
@@ -696,4 +696,103 @@ describe("jasmine spec running", function () {
env.execute([spec2.id, spec3.id, spec1.id]);
}).toThrowError(/afterAll/);
});
it("should run the tests in a consistent order when a seed is supplied", function(done) {
var actions = [];
env.randomizeTests(true);
env.seed('123456');
env.beforeEach(function () {
actions.push('topSuite beforeEach');
});
env.afterEach(function () {
actions.push('topSuite afterEach');
});
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.it('does it 1', function() {
actions.push('outer it 1');
});
env.describe('Inner 1', function() {
env.beforeEach(function() {
actions.push('inner 1 beforeEach');
});
env.afterEach(function() {
actions.push('inner 1 afterEach');
});
env.it('does it 2', function() {
actions.push('inner 1 it');
});
});
env.it('does it 3', function() {
actions.push('outer it 2');
});
env.describe('Inner 2', function() {
env.beforeEach(function() {
actions.push('inner 2 beforeEach');
});
env.afterEach(function() {
actions.push('inner 2 afterEach');
});
env.it('does it 2', function() {
actions.push('inner 2 it');
});
});
});
var assertions = function() {
var expected = [
'topSuite beforeEach',
'outer beforeEach',
'outer it 2',
'outer afterEach',
'topSuite afterEach',
'topSuite beforeEach',
'outer beforeEach',
'inner 2 beforeEach',
'inner 2 it',
'inner 2 afterEach',
'outer afterEach',
'topSuite afterEach',
'topSuite beforeEach',
'outer beforeEach',
'inner 1 beforeEach',
'inner 1 it',
'inner 1 afterEach',
'outer afterEach',
'topSuite afterEach',
'topSuite beforeEach',
'outer beforeEach',
'outer it 1',
'outer afterEach',
'topSuite afterEach'
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});

View File

@@ -0,0 +1,81 @@
describe("toHaveBeenCalledTimes", function() {
it("passes when the actual matches the expected", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
calledSpy = j$.createSpy('called-spy'),
result;
calledSpy();
result = matcher.compare(calledSpy, 1);
expect(result.pass).toBe(true);
});
it("fails when expected numbers is not supplied", function(){
var matcher = j$.matchers.toHaveBeenCalledTimes(),
spy = j$.createSpy('spy'),
result;
spy();
expect(function() {
matcher.compare(spy);
}).toThrowError('Expected times failed is required as an argument.');
});
it("fails when the actual was called less than the expected", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
uncalledSpy = j$.createSpy('uncalled spy'),
result;
result = matcher.compare(uncalledSpy, 2);
expect(result.pass).toBe(false);
});
it("fails when the actual was called more than expected", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
uncalledSpy = j$.createSpy('uncalled spy'),
result;
uncalledSpy();
uncalledSpy();
result = matcher.compare(uncalledSpy, 1);
expect(result.pass).toBe(false);
});
it("throws an exception when the actual is not a spy", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
fn = function() {};
expect(function() {
matcher.compare(fn);
}).toThrowError("Expected a spy, but got Function.");
});
it("has a custom message on failure that tells it was called only once", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
spy = j$.createSpy('sample-spy'),
result;
spy();
spy();
spy();
spy();
result = matcher.compare(spy, 1);
expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
});
it("has a custom message on failure that tells how many times it was called", function() {
var matcher = j$.matchers.toHaveBeenCalledTimes(),
spy = j$.createSpy('sample-spy'),
result;
spy();
spy();
spy();
spy();
result = matcher.compare(spy, 2);
expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
});
});

View File

@@ -146,7 +146,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new Error();
},
@@ -162,7 +162,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
CustomError = function CustomError(arg) { arg.x },
fn = function() {
throw new CustomError({ x: 1 });
@@ -181,7 +181,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new Error();
},
@@ -197,7 +197,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new TypeError("foo");
},
@@ -213,7 +213,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
CustomError = function CustomError(arg) { this.message = arg.message },
fn = function() {
throw new CustomError({message: "foo"});
@@ -232,7 +232,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new TypeError("foo");
},
@@ -248,7 +248,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new TypeError("foo");
},
@@ -264,7 +264,7 @@ describe("toThrowError", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
matcher = j$.matchers.toThrowError(),
fn = function() {
throw new TypeError("foo");
},

View File

@@ -14,20 +14,20 @@ describe("New HtmlReporter", function() {
// Main top-level elements
expect(container.querySelector("div.jasmine_html-reporter")).toBeTruthy();
expect(container.querySelector("div.banner")).toBeTruthy();
expect(container.querySelector("div.alert")).toBeTruthy();
expect(container.querySelector("div.results")).toBeTruthy();
expect(container.querySelector("div.jasmine-banner")).toBeTruthy();
expect(container.querySelector("div.jasmine-alert")).toBeTruthy();
expect(container.querySelector("div.jasmine-results")).toBeTruthy();
expect(container.querySelector("ul.symbol-summary")).toBeTruthy();
expect(container.querySelector("ul.jasmine-symbol-summary")).toBeTruthy();
// title banner
var banner = container.querySelector(".banner");
var banner = container.querySelector(".jasmine-banner");
var title = banner.querySelector("a.title");
var title = banner.querySelector("a.jasmine-title");
expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/');
expect(title.getAttribute('target')).toEqual('_blank');
var version = banner.querySelector(".version"),
var version = banner.querySelector(".jasmine-version"),
versionText = 'textContent' in version ? version.textContent : version.innerText;
expect(versionText).toEqual(j$.version);
});
@@ -90,8 +90,8 @@ describe("New HtmlReporter", function() {
failedExpectations: []
});
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("empty");
var specEl = container.querySelector('.jasmine-symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("jasmine-empty");
});
it("reports the status symbol of a disabled spec", function() {
@@ -108,8 +108,8 @@ describe("New HtmlReporter", function() {
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("disabled");
var specEl = container.querySelector('.jasmine-symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("jasmine-disabled");
expect(specEl.getAttribute("id")).toEqual("spec_789");
expect(specEl.getAttribute("title")).toEqual("symbols should have titles");
});
@@ -128,8 +128,8 @@ describe("New HtmlReporter", function() {
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("pending");
var specEl = container.querySelector('.jasmine-symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("jasmine-pending");
expect(specEl.getAttribute("id")).toEqual("spec_789");
});
@@ -147,9 +147,9 @@ describe("New HtmlReporter", function() {
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
var statuses = container.querySelector(".symbol-summary");
var statuses = container.querySelector(".jasmine-symbol-summary");
var specEl = statuses.querySelector("li");
expect(specEl.getAttribute("class")).toEqual("passed");
expect(specEl.getAttribute("class")).toEqual("jasmine-passed");
expect(specEl.getAttribute("id")).toEqual("spec_123");
});
@@ -173,8 +173,8 @@ describe("New HtmlReporter", function() {
passedExpectations: []
});
var specEl = container.querySelector(".symbol-summary li");
expect(specEl.getAttribute("class")).toEqual("failed");
var specEl = container.querySelector(".jasmine-symbol-summary li");
expect(specEl.getAttribute("class")).toEqual("jasmine-failed");
expect(specEl.getAttribute("id")).toEqual("spec_345");
});
});
@@ -198,11 +198,11 @@ describe("New HtmlReporter", function() {
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] });
reporter.jasmineDone({});
var alertBars = container.querySelectorAll(".alert .bar");
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
expect(alertBars.length).toEqual(3);
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
expect(alertBars[1].getAttribute("class")).toEqual('bar errored');
expect(alertBars[1].getAttribute("class")).toEqual('jasmine-bar jasmine-errored');
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
});
});
@@ -238,7 +238,7 @@ describe("New HtmlReporter", function() {
reporter.suiteDone({id: 1});
reporter.jasmineDone({});
var summary = container.querySelector('.summary');
var summary = container.querySelector('.jasmine-summary');
var suite = summary.childNodes[0];
var specs = suite.childNodes[1];
var spec = specs.childNodes[0];
@@ -266,7 +266,7 @@ describe("New HtmlReporter", function() {
timer.elapsed.and.returnValue(100);
reporter.jasmineDone();
var duration = container.querySelector(".alert .duration");
var duration = container.querySelector(".jasmine-alert .jasmine-duration");
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
});
@@ -334,7 +334,7 @@ describe("New HtmlReporter", function() {
reporter.suiteDone({id: 1});
reporter.jasmineDone({});
var summary = container.querySelector(".summary");
var summary = container.querySelector(".jasmine-summary");
expect(summary.childNodes.length).toEqual(1);
@@ -346,7 +346,7 @@ describe("New HtmlReporter", function() {
var node = outerSuite.childNodes[i];
classes.push(node.getAttribute("class"));
}
expect(classes).toEqual(["suite-detail", "specs", "suite", "specs"]);
expect(classes).toEqual(["jasmine-suite-detail", "jasmine-specs", "jasmine-suite", "jasmine-specs"]);
var suiteDetail = outerSuite.childNodes[0];
var suiteLink = suiteDetail.childNodes[0];
@@ -355,7 +355,7 @@ describe("New HtmlReporter", function() {
var specs = outerSuite.childNodes[1];
var spec = specs.childNodes[0];
expect(spec.getAttribute("class")).toEqual("passed");
expect(spec.getAttribute("class")).toEqual("jasmine-passed");
expect(spec.getAttribute("id")).toEqual("spec-123");
var specLink = spec.childNodes[0];
@@ -384,18 +384,18 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var trigger = container.querySelector('.run-options .trigger'),
payload = container.querySelector('.run-options .payload');
var trigger = container.querySelector('.jasmine-run-options .jasmine-trigger'),
payload = container.querySelector('.jasmine-run-options .jasmine-payload');
expect(payload.className).not.toContain('open');
expect(payload.className).not.toContain('jasmine-open');
trigger.onclick();
expect(payload.className).toContain('open');
expect(payload.className).toContain('jasmine-open');
trigger.onclick();
expect(payload.className).not.toContain('open');
expect(payload.className).not.toContain('jasmine-open');
});
describe("UI for raising/catching exceptions", function() {
@@ -419,7 +419,7 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var raisingExceptionsUI = container.querySelector(".raise");
var raisingExceptionsUI = container.querySelector(".jasmine-raise");
expect(raisingExceptionsUI.checked).toBe(false);
});
@@ -444,7 +444,7 @@ describe("New HtmlReporter", function() {
env.catchExceptions(false);
reporter.jasmineDone({});
var raisingExceptionsUI = container.querySelector(".raise");
var raisingExceptionsUI = container.querySelector(".jasmine-raise");
expect(raisingExceptionsUI.checked).toBe(true);
});
@@ -470,7 +470,7 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var input = container.querySelector(".raise");
var input = container.querySelector(".jasmine-raise");
input.click();
expect(exceptionsClickHandler).toHaveBeenCalled();
});
@@ -497,7 +497,7 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var throwingExpectationsUI = container.querySelector(".throw");
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
expect(throwingExpectationsUI.checked).toBe(false);
});
@@ -523,7 +523,7 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var throwingExpectationsUI = container.querySelector(".throw");
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
expect(throwingExpectationsUI.checked).toBe(true);
});
@@ -549,13 +549,149 @@ describe("New HtmlReporter", function() {
reporter.initialize();
reporter.jasmineDone({});
var throwingExpectationsUI = container.querySelector(".throw");
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
throwingExpectationsUI.click();
expect(throwingExceptionHandler).toHaveBeenCalled();
});
});
describe("UI for running tests in random order", function() {
it("should be unchecked if not randomizing", function() {
var env = new j$.Env(),
container = document.createElement("div"),
getContainer = function() {
return container;
},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
}
});
reporter.initialize();
reporter.jasmineDone({});
var randomUI = container.querySelector(".jasmine-random");
expect(randomUI.checked).toBe(false);
});
it("should be checked if randomizing", function() {
var env = new j$.Env(),
container = document.createElement("div"),
getContainer = function() {
return container;
},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
}
});
env.randomizeTests(true);
reporter.initialize();
reporter.jasmineDone({});
var randomUI = container.querySelector(".jasmine-random");
expect(randomUI.checked).toBe(true);
});
it("should affect the query param for random tests", function() {
var env = new j$.Env(),
container = document.createElement("div"),
randomHandler = jasmine.createSpy('randomHandler'),
getContainer = function() {
return container;
},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
onRandomClick: randomHandler,
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
}
});
reporter.initialize();
reporter.jasmineDone({});
var randomUI = container.querySelector(".jasmine-random");
randomUI.click();
expect(randomHandler).toHaveBeenCalled();
});
it("should show the seed bar if randomizing", function() {
var env = new j$.Env(),
container = document.createElement("div"),
getContainer = function() {
return container;
},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
}
});
reporter.initialize();
reporter.jasmineDone({
order: {
random: true,
seed: '424242'
}
});
var seedBar = container.querySelector(".jasmine-seed-bar");
var seedBarText = 'textContent' in seedBar ? seedBar.textContent : seedBar.innerText;
expect(seedBarText).toBe(', randomized with seed 424242');
var seedLink = container.querySelector(".jasmine-seed-bar a");
expect(seedLink.getAttribute('href')).toBe('?seed=424242');
});
it("should not show the current seed bar if not randomizing", function() {
var env = new j$.Env(),
container = document.createElement("div"),
getContainer = function() {
return container;
},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
return document.createTextNode.apply(document, arguments);
}
});
reporter.initialize();
reporter.jasmineDone();
var seedBar = container.querySelector(".jasmine-seed-bar");
expect(seedBar).toBeNull();
});
});
it("shows a message if no specs are run", function(){
var env, container, reporter;
env = new j$.Env();
@@ -572,8 +708,8 @@ describe("New HtmlReporter", function() {
reporter.jasmineStarted({});
reporter.jasmineDone({});
var alertBars = container.querySelectorAll(".alert .bar");
expect(alertBars[0].getAttribute('class')).toMatch(/skipped/);
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-skipped/);
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
});
@@ -612,21 +748,21 @@ describe("New HtmlReporter", function() {
});
it("reports the specs counts", function() {
var alertBars = container.querySelectorAll(".alert .bar");
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
expect(alertBars.length).toEqual(1);
expect(alertBars[0].getAttribute('class')).toMatch(/passed/);
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-passed/);
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
});
it("reports no failure details", function() {
var specFailure = container.querySelector(".failures");
var specFailure = container.querySelector(".jasmine-failures");
expect(specFailure.childNodes.length).toEqual(0);
});
it("reports no pending specs", function() {
var alertBar = container.querySelector(".alert .bar");
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/);
});
@@ -662,19 +798,19 @@ describe("New HtmlReporter", function() {
});
it("reports the pending specs count", function() {
var alertBar = container.querySelector(".alert .bar");
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
expect(alertBar.innerHTML).toMatch(/1 spec, 0 failures, 1 pending spec/);
});
it("reports no failure details", function() {
var specFailure = container.querySelector(".failures");
var specFailure = container.querySelector(".jasmine-failures");
expect(specFailure.childNodes.length).toEqual(0);
});
it("displays the custom pending reason", function() {
var pendingDetails = container.querySelector(".summary .pending");
var pendingDetails = container.querySelector(".jasmine-summary .jasmine-pending");
expect(pendingDetails.innerHTML).toContain("my custom pending reason");
});
@@ -721,37 +857,37 @@ describe("New HtmlReporter", function() {
});
it("reports the specs counts", function() {
var alertBar = container.querySelector(".alert .bar");
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
expect(alertBar.getAttribute('class')).toMatch(/failed/);
expect(alertBar.getAttribute('class')).toMatch(/jasmine-failed/);
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
});
it("reports failure messages and stack traces", function() {
var specFailures = container.querySelector(".failures");
var specFailures = container.querySelector(".jasmine-failures");
var failure = specFailures.childNodes[0];
expect(failure.getAttribute("class")).toMatch(/failed/);
expect(failure.getAttribute("class")).toMatch(/spec-detail/);
expect(failure.getAttribute("class")).toMatch(/jasmine-failed/);
expect(failure.getAttribute("class")).toMatch(/jasmine-spec-detail/);
var specDiv = failure.childNodes[0];
expect(specDiv.getAttribute("class")).toEqual("description");
expect(specDiv.getAttribute("class")).toEqual("jasmine-description");
var specLink = specDiv.childNodes[0];
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
expect(specLink.getAttribute("href")).toEqual("?foo=bar&spec=a suite with a failing spec");
var message = failure.childNodes[1].childNodes[0];
expect(message.getAttribute("class")).toEqual("result-message");
expect(message.getAttribute("class")).toEqual("jasmine-result-message");
expect(message.innerHTML).toEqual("a failure message");
var stackTrace = failure.childNodes[1].childNodes[1];
expect(stackTrace.getAttribute("class")).toEqual("stack-trace");
expect(stackTrace.getAttribute("class")).toEqual("jasmine-stack-trace");
expect(stackTrace.innerHTML).toEqual("a stack trace");
});
it("allows switching between failure details and the spec summary", function() {
var menuBar = container.querySelectorAll(".bar")[1];
var menuBar = container.querySelectorAll(".jasmine-bar")[1];
expect(menuBar.getAttribute("class")).not.toMatch(/hidden/);
@@ -762,7 +898,7 @@ describe("New HtmlReporter", function() {
it("sets the reporter to 'Failures List' mode", function() {
var reporterNode = container.querySelector(".jasmine_html-reporter");
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
expect(reporterNode.getAttribute("class")).toMatch("jasmine-failure-list");
});
});
});

View File

@@ -5,5 +5,6 @@
],
"helper_files": [
"helpers/nodeDefineJasmineUnderTest.js"
]
],
"random": true
}

View File

@@ -7,3 +7,4 @@ helpers:
spec_files:
- 'performance/performance_test.js'
spec_dir: spec
random: true

View File

@@ -7,5 +7,6 @@
],
"helpers": [
"helpers/nodeDefineJasmineUnderTest.js"
]
],
"random": true
}

View File

@@ -22,5 +22,5 @@ spec_files:
- '**/*[Ss]pec.js'
- '!npmPackage/**/*'
spec_dir: spec
random: true

View File

@@ -20,6 +20,8 @@ getJasmineRequireObj().Env = function(j$) {
var currentlyExecutingSuites = [];
var currentDeclarationSuite = null;
var throwOnExpectationFailure = false;
var random = false;
var seed = null;
var currentSuite = function() {
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
@@ -169,6 +171,21 @@ getJasmineRequireObj().Env = function(j$) {
return throwOnExpectationFailure;
};
this.randomizeTests = function(value) {
random = !!value;
};
this.randomTests = function() {
return random;
};
this.seed = function(value) {
if (value) {
seed = value;
}
return seed;
};
var queueRunnerFactory = function(options) {
options.catchException = catchException;
options.clearStack = options.clearStack || clearStack;
@@ -200,6 +217,12 @@ getJasmineRequireObj().Env = function(j$) {
runnablesToRun = [topSuite.id];
}
}
var order = new j$.Order({
random: random,
seed: seed
});
var processor = new j$.TreeProcessor({
tree: topSuite,
runnableIds: runnablesToRun,
@@ -215,6 +238,9 @@ getJasmineRequireObj().Env = function(j$) {
}
currentlyExecutingSuites.pop();
reporter.suiteDone(result);
},
orderChildren: function(node) {
return order.sort(node.children);
}
});
@@ -226,7 +252,11 @@ getJasmineRequireObj().Env = function(j$) {
totalSpecsDefined: totalSpecsDefined
});
processor.execute(reporter.jasmineDone);
processor.execute(function() {
reporter.jasmineDone({
order: order
});
});
};
this.addReporter = function(reporterToAdd) {
@@ -261,13 +291,20 @@ getJasmineRequireObj().Env = function(j$) {
this.describe = function(description, specDefinitions) {
var suite = suiteFactory(description);
if (specDefinitions.length > 0) {
throw new Error('describe does not expect a done parameter');
}
if (currentDeclarationSuite.markedPending) {
suite.pend();
}
addSpecsToSuite(suite, specDefinitions);
return suite;
};
this.xdescribe = function(description, specDefinitions) {
var suite = this.describe(description, specDefinitions);
suite.disable();
var suite = suiteFactory(description);
suite.pend();
addSpecsToSuite(suite, specDefinitions);
return suite;
};
@@ -373,19 +410,22 @@ getJasmineRequireObj().Env = function(j$) {
this.it = function(description, fn, timeout) {
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
if (currentDeclarationSuite.markedPending) {
spec.pend();
}
currentDeclarationSuite.addChild(spec);
return spec;
};
this.xit = function() {
var spec = this.it.apply(this, arguments);
spec.pend();
spec.pend('Temporarily disabled with xit');
return spec;
};
this.fit = function(){
var spec = this.it.apply(this, arguments);
this.fit = function(description, fn, timeout){
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
unfocusAncestor();
return spec;

View File

@@ -11,6 +11,7 @@ getJasmineRequireObj().JsApiReporter = function() {
this.started = false;
this.finished = false;
this.runDetails = {};
this.jasmineStarted = function() {
this.started = true;
@@ -20,8 +21,9 @@ getJasmineRequireObj().JsApiReporter = function() {
var executionTime;
this.jasmineDone = function() {
this.jasmineDone = function(runDetails) {
this.finished = true;
this.runDetails = runDetails;
executionTime = timer.elapsed();
status = 'done';
};

46
src/core/Order.js Normal file
View File

@@ -0,0 +1,46 @@
/*jshint bitwise: false*/
getJasmineRequireObj().Order = function() {
function Order(options) {
this.random = 'random' in options ? options.random : true;
var seed = this.seed = options.seed || generateSeed();
this.sort = this.random ? randomOrder : naturalOrder;
function naturalOrder(items) {
return items;
}
function randomOrder(items) {
var copy = items.slice();
copy.sort(function(a, b) {
return jenkinsHash(seed + a.id) - jenkinsHash(seed + b.id);
});
return copy;
}
function generateSeed() {
return String(Math.random()).slice(-5);
}
// Bob Jenkins One-at-a-Time Hash algorithm is a non-cryptographic hash function
// used to get a different output when the key changes slighly.
// We use your return to sort the children randomly in a consistent way when
// used in conjunction with a seed
function jenkinsHash(key) {
var hash, i;
for(hash = i = 0; i < key.length; ++i) {
hash += key.charCodeAt(i);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
}
return Order;
};

View File

@@ -30,6 +30,8 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('HTMLNode');
} else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')');
} else if (value.toString && typeof value === 'object' && !(value instanceof Array) && value.toString !== Object.prototype.toString) {
this.emitScalar(value.toString());
} else if (j$.util.arrayContains(this.seen, value)) {
this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {

View File

@@ -73,7 +73,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
if (queueableFn.timeout) {
timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() {
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
onException(error, queueableFn);
onException(error);
next();
}, queueableFn.timeout()]]);
}
@@ -86,12 +86,12 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
}
function onException(e, queueableFn) {
function onException(e) {
self.onException(e);
}
function handleException(e, queueableFn) {
onException(e, queueableFn);
onException(e);
if (!self.catchException(e)) {
//TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..

View File

@@ -22,6 +22,17 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error(methodName + ' has already been spied upon');
}
var descriptor;
try {
descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
} catch(e) {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}
if (descriptor && !(descriptor.writable || descriptor.set)) {
throw new Error(methodName + ' is not declared writable or has no setter');
}
var spy = j$.createSpy(methodName, obj[methodName]);
currentSpies().push({

View File

@@ -42,6 +42,10 @@ getJasmineRequireObj().Suite = function(j$) {
this.disabled = true;
};
Suite.prototype.pend = function(message) {
this.markedPending = true;
};
Suite.prototype.beforeEach = function(fn) {
this.beforeFns.unshift(fn);
};
@@ -67,6 +71,10 @@ getJasmineRequireObj().Suite = function(j$) {
return 'disabled';
}
if (this.markedPending) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {

View File

@@ -5,6 +5,7 @@ getJasmineRequireObj().TreeProcessor = function() {
queueRunnerFactory = attrs.queueRunnerFactory,
nodeStart = attrs.nodeStart || function() {},
nodeComplete = attrs.nodeComplete || function() {},
orderChildren = attrs.orderChildren || function(node) { return node.children; },
stats = { valid: true },
processed = false,
defaultMin = Infinity,
@@ -68,8 +69,10 @@ getJasmineRequireObj().TreeProcessor = function() {
} else {
var hasExecutableChild = false;
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
var orderedChildren = orderChildren(node);
for (var i = 0; i < orderedChildren.length; i++) {
var child = orderedChildren[i];
processNode(child, parentEnabled);
@@ -86,7 +89,7 @@ getJasmineRequireObj().TreeProcessor = function() {
executable: hasExecutableChild
};
segmentChildren(node, stats[node.id], executableIndex);
segmentChildren(node, orderedChildren, stats[node.id], executableIndex);
if (!node.canBeReentered() && stats[node.id].segments.length > 1) {
stats = { valid: false };
@@ -102,11 +105,11 @@ getJasmineRequireObj().TreeProcessor = function() {
return executableIndex === undefined ? defaultMax : executableIndex;
}
function segmentChildren(node, nodeStats, executableIndex) {
function segmentChildren(node, orderedChildren, nodeStats, executableIndex) {
var currentSegment = { index: 0, owner: node, nodes: [], min: startingMin(executableIndex), max: startingMax(executableIndex) },
result = [currentSegment],
lastMax = defaultMax,
orderedChildSegments = orderChildSegments(node.children);
orderedChildSegments = orderChildSegments(orderedChildren);
function isSegmentBoundary(minIndex) {
return lastMax !== defaultMax && minIndex !== defaultMin && lastMax < minIndex - 1;
@@ -132,30 +135,29 @@ getJasmineRequireObj().TreeProcessor = function() {
}
function orderChildSegments(children) {
var result = [];
var specifiedOrder = [],
unspecifiedOrder = [];
for (var i = 0; i < children.length; i++) {
var child = children[i],
segments = stats[child.id].segments;
for (var j = 0; j < segments.length; j++) {
result.push(segments[j]);
var seg = segments[j];
if (seg.min === defaultMin) {
unspecifiedOrder.push(seg);
} else {
specifiedOrder.push(seg);
}
}
}
result.sort(function(a, b) {
if (a.min === null) {
return b.min === null ? 0 : 1;
}
if (b.min === null) {
return -1;
}
specifiedOrder.sort(function(a, b) {
return a.min - b.min;
});
return result;
return specifiedOrder.concat(unspecifiedOrder);
}
function executeNode(node, segmentNumber) {

View File

@@ -1,6 +1,12 @@
getJasmineRequireObj().Any = function(j$) {
function Any(expectedObject) {
if (typeof expectedObject === 'undefined') {
throw new TypeError(
'jasmine.any() expects to be passed a constructor function. ' +
'Please pass one or use jasmine.anything() to match any object.'
);
}
this.expectedObject = expectedObject;
}

View File

@@ -14,6 +14,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
'toEqual',
'toHaveBeenCalled',
'toHaveBeenCalledWith',
'toHaveBeenCalledTimes',
'toMatch',
'toThrow',
'toThrowError'

View File

@@ -0,0 +1,30 @@
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
function toHaveBeenCalledTimes() {
return {
compare: function(actual, expected) {
if (!j$.isSpy(actual)) {
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
}
var args = Array.prototype.slice.call(arguments, 0),
result = { pass: false };
if(!expected){
throw new Error('Expected times failed is required as an argument.');
}
actual = args[0];
var calls = actual.calls.count();
var timesMessage = expected === 1 ? 'once' : expected + ' times';
result.pass = calls === expected;
result.message = result.pass ?
'Expected spy ' + actual.and.identity() + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
'Expected spy ' + actual.and.identity() + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
return result;
}
};
}
return toHaveBeenCalledTimes;
};

View File

@@ -1,5 +1,5 @@
getJasmineRequireObj().toThrowError = function(j$) {
function toThrowError (util) {
function toThrowError () {
return {
compare: function(actual) {
var threw = false,

View File

@@ -2,7 +2,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
var jasmineRequire;
if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
if (typeof global !== 'undefined') {
jasmineGlobal = global;
} else {
jasmineGlobal = {};
}
jasmineRequire = exports;
} else {
if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
@@ -46,6 +50,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.Timer = jRequire.Timer();
j$.TreeProcessor = jRequire.TreeProcessor();
j$.version = jRequire.version();
j$.Order = jRequire.Order();
j$.matchers = jRequire.requireMatchers(jRequire, j$);

View File

@@ -12,6 +12,7 @@ jasmineRequire.HtmlReporter = function(j$) {
createTextNode = options.createTextNode,
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
onRandomClick = options.onRandomClick || function() {},
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
timer = options.timer || noopTimer,
results = [],
@@ -25,19 +26,17 @@ jasmineRequire.HtmlReporter = function(j$) {
this.initialize = function() {
clearPrior();
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
createDom('div', {className: 'banner'},
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'version'}, j$.version)
createDom('div', {className: 'jasmine-banner'},
createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'jasmine-version'}, j$.version)
),
createDom('ul', {className: 'symbol-summary'}),
createDom('div', {className: 'alert'}),
createDom('div', {className: 'results'},
createDom('div', {className: 'failures'})
createDom('ul', {className: 'jasmine-symbol-summary'}),
createDom('div', {className: 'jasmine-alert'}),
createDom('div', {className: 'jasmine-results'},
createDom('div', {className: 'jasmine-failures'})
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find('.symbol-summary');
};
var totalSpecsDefined;
@@ -46,7 +45,7 @@ jasmineRequire.HtmlReporter = function(j$) {
timer.start();
};
var summary = createDom('div', {className: 'summary'});
var summary = createDom('div', {className: 'jasmine-summary'});
var topResults = new j$.ResultsNode({}, '', null),
currentParent = topResults;
@@ -82,8 +81,12 @@ jasmineRequire.HtmlReporter = function(j$) {
specsExecuted++;
}
if (!symbols){
symbols = find('.jasmine-symbol-summary');
}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'empty' : result.status,
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
id: 'spec_' + result.id,
title: result.fullName
}
@@ -93,18 +96,18 @@ jasmineRequire.HtmlReporter = function(j$) {
failureCount++;
var failure =
createDom('div', {className: 'spec-detail failed'},
createDom('div', {className: 'description'},
createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
createDom('div', {className: 'jasmine-description'},
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
),
createDom('div', {className: 'messages'})
createDom('div', {className: 'jasmine-messages'})
);
var messages = failure.childNodes[1];
for (var i = 0; i < result.failedExpectations.length; i++) {
var expectation = result.failedExpectations[i];
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
}
failures.push(failure);
@@ -115,86 +118,106 @@ jasmineRequire.HtmlReporter = function(j$) {
}
};
this.jasmineDone = function() {
var banner = find('.banner');
var alert = find('.alert');
alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
this.jasmineDone = function(doneResult) {
var banner = find('.jasmine-banner');
var alert = find('.jasmine-alert');
var order = doneResult && doneResult.order;
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
banner.appendChild(
createDom('div', { className: 'run-options' },
createDom('span', { className: 'trigger' }, 'Options'),
createDom('div', { className: 'payload' },
createDom('div', { className: 'exceptions' },
createDom('div', { className: 'jasmine-run-options' },
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
createDom('div', { className: 'jasmine-payload' },
createDom('div', { className: 'jasmine-exceptions' },
createDom('input', {
className: 'raise',
id: 'raise-exceptions',
className: 'jasmine-raise',
id: 'jasmine-raise-exceptions',
type: 'checkbox'
}),
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')),
createDom('div', { className: 'throw-failures' },
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-raise-exceptions' }, 'raise exceptions')),
createDom('div', { className: 'jasmine-throw-failures' },
createDom('input', {
className: 'throw',
id: 'throw-failures',
className: 'jasmine-throw',
id: 'jasmine-throw-failures',
type: 'checkbox'
}),
createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure'))
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
createDom('div', { className: 'jasmine-random-order' },
createDom('input', {
className: 'jasmine-random',
id: 'jasmine-random-order',
type: 'checkbox'
}),
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
)
));
var raiseCheckbox = find('#raise-exceptions');
var raiseCheckbox = find('#jasmine-raise-exceptions');
raiseCheckbox.checked = !env.catchingExceptions();
raiseCheckbox.onclick = onRaiseExceptionsClick;
var throwCheckbox = find('#throw-failures');
var throwCheckbox = find('#jasmine-throw-failures');
throwCheckbox.checked = env.throwingExpectationFailures();
throwCheckbox.onclick = onThrowExpectationsClick;
var optionsMenu = find('.run-options'),
optionsTrigger = optionsMenu.querySelector('.trigger'),
optionsPayload = optionsMenu.querySelector('.payload'),
isOpen = /\bopen\b/;
var randomCheckbox = find('#jasmine-random-order');
randomCheckbox.checked = env.randomTests();
randomCheckbox.onclick = onRandomClick;
var optionsMenu = find('.jasmine-run-options'),
optionsTrigger = optionsMenu.querySelector('.jasmine-trigger'),
optionsPayload = optionsMenu.querySelector('.jasmine-payload'),
isOpen = /\bjasmine-open\b/;
optionsTrigger.onclick = function() {
if (isOpen.test(optionsPayload.className)) {
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
} else {
optionsPayload.className += ' open';
optionsPayload.className += ' jasmine-open';
}
};
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
alert.appendChild(
createDom('span', {className: 'bar skipped'},
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
)
);
}
var statusBarMessage = '';
var statusBarClassName = 'bar ';
var statusBarClassName = 'jasmine-bar ';
if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
statusBarClassName += (failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
} else {
statusBarClassName += 'skipped';
statusBarClassName += 'jasmine-skipped';
statusBarMessage += 'No specs found';
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
var seedBar;
if (order && order.random) {
seedBar = createDom('span', {className: 'jasmine-seed-bar'},
', randomized with seed ',
createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
);
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
for(i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
var errorBarClassName = 'bar errored';
var errorBarClassName = 'jasmine-bar jasmine-errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}
}
var results = find('.results');
var results = find('.jasmine-results');
results.appendChild(summary);
summaryList(topResults, summary);
@@ -204,8 +227,8 @@ jasmineRequire.HtmlReporter = function(j$) {
for (var i = 0; i < resultsTree.children.length; i++) {
var resultNode = resultsTree.children[i];
if (resultNode.type == 'suite') {
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'suite-detail'},
var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'jasmine-suite-detail'},
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
)
);
@@ -214,8 +237,8 @@ jasmineRequire.HtmlReporter = function(j$) {
domParent.appendChild(suiteListNode);
}
if (resultNode.type == 'spec') {
if (domParent.getAttribute('class') != 'specs') {
specListNode = createDom('ul', {className: 'specs'});
if (domParent.getAttribute('class') != 'jasmine-specs') {
specListNode = createDom('ul', {className: 'jasmine-specs'});
domParent.appendChild(specListNode);
}
var specDescription = resultNode.result.description;
@@ -227,7 +250,7 @@ jasmineRequire.HtmlReporter = function(j$) {
}
specListNode.appendChild(
createDom('li', {
className: resultNode.result.status,
className: 'jasmine-' + resultNode.result.status,
id: 'spec-' + resultNode.result.id
},
createDom('a', {href: specHref(resultNode.result)}, specDescription)
@@ -239,24 +262,24 @@ jasmineRequire.HtmlReporter = function(j$) {
if (failures.length) {
alert.appendChild(
createDom('span', {className: 'menu bar spec-list'},
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
createDom('span', {}, 'Spec List | '),
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
alert.appendChild(
createDom('span', {className: 'menu bar failure-list'},
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {}, ' | Failures ')));
find('.failures-menu').onclick = function() {
setMenuModeTo('failure-list');
find('.jasmine-failures-menu').onclick = function() {
setMenuModeTo('jasmine-failure-list');
};
find('.spec-list-menu').onclick = function() {
setMenuModeTo('spec-list');
find('.jasmine-spec-list-menu').onclick = function() {
setMenuModeTo('jasmine-spec-list');
};
setMenuModeTo('failure-list');
setMenuModeTo('jasmine-failure-list');
var failureNode = find('.failures');
var failureNode = find('.jasmine-failures');
for (var i = 0; i < failures.length; i++) {
failureNode.appendChild(failures[i]);
}
@@ -314,6 +337,10 @@ jasmineRequire.HtmlReporter = function(j$) {
return addToExistingQueryString('spec', result.fullName);
}
function seedHref(seed) {
return addToExistingQueryString('seed', seed);
}
function defaultQueryString(key, value) {
return '?' + key + '=' + value;
}

View File

@@ -46,23 +46,23 @@ body {
line-height: $line-height;
}
.banner,
.symbol-summary,
.summary,
.result-message,
.spec .description,
.spec-detail .description,
.alert .bar,
.stack-trace {
.jasmine-banner,
.jasmine-symbol-summary,
.jasmine-summary,
.jasmine-result-message,
.jasmine-spec .jasmine-description,
.jasmine-spec-detail .jasmine-description,
.jasmine-alert .jasmine-bar,
.jasmine-stack-trace {
padding-left: $margin-unit - 5px;
padding-right: $margin-unit - 5px;
}
.banner {
.jasmine-banner {
position: relative;
}
.banner .title {
.jasmine-banner .jasmine-title {
background: inline-image('jasmine-horizontal.png') no-repeat;
background: inline-image('jasmine-horizontal.svg') no-repeat, none;
@include background-size(100%);
@@ -72,7 +72,7 @@ body {
height: 25px;
}
.banner .version {
.jasmine-banner .jasmine-version {
margin-left: $margin-unit;
position: relative;
top: 6px;
@@ -85,17 +85,17 @@ body {
right: 100%;
}
.version {
.jasmine-version {
color: $faint-text-color;
}
//--- Banner ---//
.banner {
.jasmine-banner {
margin-top: $line-height;
}
.duration {
.jasmine-duration {
color: #fff;
float: right;
line-height: $line-height * 2;
@@ -104,18 +104,18 @@ body {
//--- Symbol summary ---//
.symbol-summary {
.jasmine-symbol-summary {
@include clearfix;
margin: $line-height 0;
li {
display: inline-block;
height: ($line-height / 2) + 1;
height: ($line-height / 2) + 3;
width: $line-height;
font-size: 16px;
&.passed {
&.jasmine-passed {
font-size: 14px;
&:before {
@@ -124,7 +124,7 @@ body {
}
}
&.failed {
&.jasmine-failed {
line-height: ($line-height / 2) + 2;
&:before {
@@ -135,7 +135,7 @@ body {
}
}
&.disabled {
&.jasmine-disabled {
font-size: 14px;
&:before {
@@ -144,7 +144,7 @@ body {
}
}
&.pending {
&.jasmine-pending {
line-height: 17px;
&:before {
color: $pending-color;
@@ -152,7 +152,7 @@ body {
}
}
&.empty {
&.jasmine-empty {
font-size: 14px;
&:before {
@@ -163,7 +163,7 @@ body {
}
}
.run-options {
.jasmine-run-options {
float: right;
margin-right: 5px;
border: 1px solid $jasmine-color;
@@ -171,12 +171,12 @@ body {
position: relative;
line-height: 20px;
.trigger {
.jasmine-trigger {
cursor: pointer;
padding: 8px 16px;
}
.payload {
.jasmine-payload {
position: absolute;
display: none;
right: -1px;
@@ -185,7 +185,7 @@ body {
white-space: nowrap;
padding: 4px 8px;
&.open {
&.jasmine-open {
display: block;
}
}
@@ -193,30 +193,30 @@ body {
//--- Alerts: status bars ---//
.bar {
.jasmine-bar {
line-height: $line-height * 2;
font-size: $large-font-size;
display: block;
color: #eee;
&.failed {
&.jasmine-failed {
background-color: $failing-color;
}
&.passed {
&.jasmine-passed {
background-color: $passing-color;
}
&.skipped {
&.jasmine-skipped {
background-color: $neutral-color;
}
&.errored {
&.jasmine-errored {
background-color: $failing-color;
}
&.menu {
&.jasmine-menu {
background-color: #fff;
color: $faint-text-color;
@@ -231,65 +231,29 @@ body {
}
// simplify toggle control between the two menu bars
&.spec-list {
.bar.menu.failure-list,
.results .failures {
&.jasmine-spec-list {
.jasmine-bar.jasmine-menu.jasmine-failure-list,
.jasmine-results .jasmine-failures {
display: none;
}
}
&.failure-list {
.bar.menu.spec-list,
.summary {
&.jasmine-failure-list {
.jasmine-bar.jasmine-menu.jasmine-spec-list,
.jasmine-summary {
display: none;
}
}
.running-alert {
background-color: $light-text-color;
}
//--- Results ---//
.results {
.jasmine-results {
margin-top: $line-height;
}
//--- Results menu ---//
&.showDetails {
.summaryMenuItem {
font-weight: normal;
text-decoration: inherit;
&:hover {
text-decoration: underline;
}
}
.detailsMenuItem {
font-weight: bold;
text-decoration: underline;
}
.summary {
display: none;
}
#details {
display: block;
}
}
.summaryMenuItem {
font-weight: bold;
text-decoration: underline;
}
//--- Results summary: Suites and Specs names/links ---//
.summary {
.jasmine-summary {
margin-top: $margin-unit;
ul {
@@ -298,40 +262,40 @@ body {
padding-top: 0;
padding-left: 0;
&.suite {
&.jasmine-suite {
margin-top: $margin-unit/2;
margin-bottom: $margin-unit/2
}
}
li {
&.passed a {
&.jasmine-passed a {
color: $passing-color;
}
&.failed a {
&.jasmine-failed a {
color: $failing-color;
}
&.empty a {
&.jasmine-empty a {
color: $pending-color;
}
&.pending a {
&.jasmine-pending a {
color: $pending-color;
}
&.disabled a {
&.jasmine-disabled a {
color: $neutral-color;
}
}
}
.description+.suite {
.jasmine-description + .jasmine-suite {
margin-top: 0;
}
.suite {
.jasmine-suite {
margin-top: $margin-unit;
a {
@@ -341,11 +305,11 @@ body {
//--- Failure details ---//
.failures {
.spec-detail {
.jasmine-failures {
.jasmine-spec-detail {
margin-bottom: $line-height * 2;
.description {
.jasmine-description {
background-color: $failing-color;
a {
@@ -355,7 +319,7 @@ body {
}
}
.result-message {
.jasmine-result-message {
padding-top: $line-height;
color: $text-color;
@@ -363,11 +327,11 @@ body {
white-space: pre;
}
.result-message span.result {
.jasmine-result-message span.jasmine-result {
display: block;
}
.stack-trace {
.jasmine-stack-trace {
margin: 5px 0 0 0;
max-height: $line-height * 16;
overflow: auto;

View File

@@ -2,10 +2,8 @@
if [ $USE_SAUCE == true ]
then
if [ $TRAVIS_SECURE_ENV_VARS == true ]
if [ $TRAVIS_SECURE_ENV_VARS != true ]
then
curl -L https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
else
echo "skipping tests since we can't use sauce"
exit 0
fi