pc

phantom-chai

Chai for phantomjs scripts

Showing:

Popularity

Downloads/wk

3

GitHub Stars

2

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

phantom-chai

Chai assertions for phantomjs scripts

Usage

npm install phantom-chai chai --save-dev

Usage in phantomjs script

    var chai = require('phantom-chai')()
        , assert = chai.assert;

    var page = webpage.create();

    page.open('http://localhost/test', function (status) {
        assert.equal(status, 'success');
        assert.equal(page.title, 'My page');
        phantom.exit();
    });

If any of the assertions throws, script will log the error and the stack and will terminate. Internally phantom.exit(1) is called.

You can pass custom teardown function in options, e.g. to delete test data and to kill child processes:

    var chai = require('phantom-chai')({ teardown: teardown });

    function teardown() {
        childProcess.kill('SIGKILL');
        phantom.exit(1);
    }

At the moment only 'assert' style assertions are supported.

Dependencies

chai is NOT a dependency of phantom-chai, it should be installed separately.

It allows you using any version of chai with phantom-chai and upgrading chai without upgading phantom-chai.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100