Last active
June 22, 2016 10:50
-
-
Save DamianMullins/3e4f9ea0cc910d544d98647e437dfc6b to your computer and use it in GitHub Desktop.
Testing with Mocha, Chai, and jsdom global.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
describe('dom', () => { | |
before(function () { | |
this.jsdom = require('jsdom-global')() | |
}) | |
after(function () { | |
this.jsdom() | |
}) | |
it('window', () => { | |
expect(window).to.equal(window); | |
}); | |
it('document', () => { | |
expect(document).to.equal(document); | |
}); | |
}); | |
describe('elements', () => { | |
before(function () { | |
this.jsdom = require('jsdom-global')('<p>Hello</p>') | |
}) | |
after(function () { | |
this.jsdom() | |
}) | |
it('jsdom', () => { | |
console.log(document.querySelector('.test')); | |
expect(document.querySelector('p').innerHTML).to.equal('Hello'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment