A plugin for Chai that wraps ZombieJS assertions, but with a better DSL.
If you are using should
or expect
in Chai, instead of writing
browser.assert.status(200)
you can write
browser.should.have.status(200)
expect(browser).to.have.status(200)
On your specHelper.js make sure you load zombied-chai
like below:
'use strict'
var chai = require('chai')
var zombiedChai = require('zombied-chai')
chai.should()
chai.use(zombiedChai)
Not all assertions are implemented yet but you already can do some basic things:
Zombie assertionbrowser.assert |
Zombied-Chai assertionbrowser.should.be/have |
---|---|
.success |
.successful |
.status(200) |
.status(200) |
.element('#selector') |
.element('#selector') |
.className('#selector', 'foo') |
.element('#selector').withClass('foo') |
.hasNoClass('#selector', 'foo') |
.element('#selector').withoutClass('foo') |
.attribute('#selector', 'foo', 'bar') |
.element('#selector').withAttribute('foo', 'bar') |
.attribute('#selector', 'data-foo', 'bar') |
.element('#selector').withData('foo', 'bar') |
.hasFocus('#selector') |
.element('#selector').focused |
.link('#selector', 'link text') |
.link('#selector', 'link text') |
.link('#selector', 'link text', 'url') |
.link('#selector', 'link text').withHref('#href') |
`.url('url | obj |
`.url('url | obj |
`.url('url | obj |
You can chain all this:
.url().withHost('host').withPath('/').withQuery('a', 'b')
Check the tests for all assertions. More assertions will come in time.