You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+12-26
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,11 @@
1
1
# PhantomJS Runners for Mocha
2
2
3
-
[Mocha](http://mochajs.org/) is a feature-rich JavaScript test framework running on node and the browser. Along with the [Chai](http://chaijs.com) assertion library they make an impressive combo. [PhantomJS](http://phantomjs.org) is a headless WebKit with a JavaScript/CoffeeScript API. It has fast and native support for various web standards like DOM handling, CSS selectors, JSON, Canvas, and SVG.
3
+
[Mocha](http://mochajs.org/) is a feature-rich JavaScript test framework running on node and the browser. Along with the [Chai](http://chaijs.com) assertion library they make an impressive combo. [PhantomJS](http://phantomjs.org) is a headless WebKit with a JavaScript API.
4
4
5
-
The mocha-phantomjs project provides a `mocha-phantomjs.coffee` script file and extensions to drive PhantomJS while testing your HTML pages with Mocha from the console. The preferred usage is to install `mocha-phantomjs` via node's packaged modules and use the `mocha-phantomjs` binary wrapper. Tested with Mocha 1.12.x, Chai 1.7.x, and PhantomJS 1.9.1.
6
-
7
-
***Since version 3.0 of mocha-phantomjs, you must use PhantomJS 1.9.1 or higher.**
5
+
Since 4.0, the phantomjs code now is in [mocha-phantomjs-core](https://github.com/nathanboktae/mocha-phantomjs-core). If you need full control over which phantomjs version to use and where to get it, or want to use it more programatically like a build system plugin, please use that package directly. This project is a node.js CLI around it.
@@ -21,21 +18,16 @@ Proper exit status codes from PhantomJS using Mocha's failures count. So in stan
21
18
22
19
### Mixed Mode Runs
23
20
24
-
You can use your existing Mocha HTML file reporters side by side with mocha-phantomjs. This gives you the option to run your tests both in a browser or with PhantomJS. Since mocha-phantomjs needs to control when the `run()` command is sent to the mocha object, we accomplish this by setting the `mochaPhantomJS` on the `window` object to `true`. Below, in the usage section, is an example of a HTML structure that can be used both by opening the file in your browser or choice or using mocha-phantomjs.
25
-
21
+
You can use your existing Mocha HTML file reporters side by side with mocha-phantomjs. This gives you the option to run your tests both in a browser or with PhantomJS, with no changes needed to your existing test setup.
26
22
27
23
# Installation
28
24
29
-
We distribute [mocha-phantomjs as an npm](https://npmjs.org/package/mocha-phantomjs) that is easy to install. Once done, you will have a `mocha-phantomjs` binary. See the next usage section for docs or use the `-h` flag.
30
-
31
-
Since 3.4, we now declare phantomjs as a peer dependency, and it will be installed adjacent to `mocha-phantomjs` automatically. You may use `-p` to provide an explicit path to phantomjs, or call phantomjs directly yourself via `phantomjs lib/mocha-phantomjs.coffee <page> <reporter> <config-as-JSON>`. The later approach is recommended for build system plugins to avoid another process fork.
32
-
33
-
Due to [a bug in phantomjs 1.9.8+](https://github.com/nathanboktae/mocha-phantomjs/issues/167), mocha-phantomjs currnently caps its peer depedency to `1.9.7-15`. If you are having install errors due to peer depdendency resolution conflics, expliclity declare your dependency as `"phantomjs": "1.9.7-15"`, or expliclity install 1.9.7, like `npm install [email protected]`.
25
+
We distribute [mocha-phantomjs as an npm package](https://npmjs.org/package/mocha-phantomjs) that is easy to install. Once done, you will have a `mocha-phantomjs` binary. See the next usage section for docs or use the `-h` flag.
Now as an node package, using `mocha-phantomjs` has never been easier. The page argument can be either a local or fully qualified path or a http or file URL. `--reporter` may be a built-in reporter or a path to your own reporter (see below). See [phantomjs WebPage settings](https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage#wiki-webpage-settings) for options that may be supplied to the `--setting` argument.
69
62
70
-
Your HTML file's structure should look something like this. The reporter set below to `html` is only needed for viewing the HTML page in your browser. The `mocha-phantomjs.coffee` script overrides that reporter value. The conditional run at the bottom allows the mixed mode feature described above.
63
+
Since 4.0, you need no modifications to your test harness markup file to run. Here is an example `test.html`:
71
64
72
65
```html
73
66
<html>
@@ -81,14 +74,13 @@ Your HTML file's structure should look something like this. The reporter set bel
81
74
<scriptsrc="mocha.js"></script>
82
75
<scriptsrc="chai.js"></script>
83
76
<script>
84
-
mocha.ui('bdd');
85
-
mocha.reporter('html');
86
-
expect =chai.expect;
77
+
mocha.ui('bdd')
78
+
expect =chai.expect
87
79
</script>
80
+
<scriptsrc="src/mycode.js"></script>
88
81
<scriptsrc="test/mycode.js"></script>
89
82
<script>
90
-
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
91
-
else { mocha.run(); }
83
+
mocha.run()
92
84
</script>
93
85
</body>
94
86
</html>
@@ -186,13 +178,7 @@ We also use Travis CI to run our tests too. The current build status:
0 commit comments