Background Image
Table of Contents Table of Contents
Previous Page  410 / 478 Next Page
Information
Show Menu
Previous Page 410 / 478 Next Page
Page Background

4. Make sure you get the latest version. On Ubuntu, use the PPA rather than the default package.

Installing node

It’s time to stop pretending we’re not in the JavaScript game. We’re doing web develop‐

ment. That means we do JavaScript. That means we’re going to end up with node.js on

our computers. It’s just the way it has to be.

Follow the instructions on the

node.js download page .

There are installers forWindows

and Mac, and repositories for popular Linux distros.

4

Once we have node, we can install phantom:

$

npm install -g phantomjs

# the -g means "system-wide". May need sudo.

Next we pull down a QUnit/PhantomJS test runner. There are several out there (I even

wrote a basic one to be able to test the QUnit listings in this book), but the best one to

get is probably the one that’s linked from the

QUnit plugins page .

At the time of writing,

its repo was at

https://github.com/jonkemp/qunit-phantomjs-runner

. The only file you

need is

runner.js

.

You should end up with this:

$

tree superlists/static/tests/

superlists/static/tests/

├── qunit.css

├── qunit.js

├── runner.js

└── sinon.js

0 directories, 4 files

Let’s try it out:

$

phantomjs superlists/static/tests/runner.js lists/static/tests/tests.html

Took 24ms to run 2 tests. 2 passed, 0 failed.

$

phantomjs superlists/static/tests/runner.js accounts/static/tests/tests.html

Took 29ms to run 11 tests. 11 passed, 0 failed.

Just to be sure, let’s deliberately break something:

lists/static/list.js (ch20l019).

$

(

'input'

).

on

(

'keypress'

,

function

() {

//$('.has-error').hide();

});

Sure enough:

$

phantomjs superlists/static/tests/runner.js lists/static/tests/tests.html

Test failed: undefined: errors should be hidden on keypress

Failed assertion: expected: false, but was: true

at file:///workspace/superlists/superlists/static/tests/qunit.js:556

at file:///workspace/superlists/lists/static/tests/tests.html:26

382

|

Chapter 20: Continuous Integration (CI)