Created
December 2, 2015 20:22
-
-
Save thibaudcolas/064c010e3b02d6243805 to your computer and use it in GitHub Desktop.
Nightmare example
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
| 'use strict'; | |
| require('mocha-generators').install(); | |
| var expect = require('chai').expect; | |
| var nightmare = require('nightmare'); | |
| describe('Test blog content', function() { | |
| this.timeout(10000); | |
| let night; | |
| before('setup nightmare instance', function() { | |
| night = nightmare({ show: true }); | |
| }); | |
| after('teardown nightmare instance', function*() { | |
| yield night.end(); | |
| }); | |
| describe('homepage', function() { | |
| before('go to page', function*() { | |
| yield night.goto('http://blog.thib.me/'); | |
| }); | |
| it('page title', function*() { | |
| var title = yield night.evaluate(function() { | |
| return document.querySelector('header h1').innerText; | |
| }); | |
| expect(title).to.equal('ThibWeb\'s Blog'); | |
| }); | |
| it('articles on homepage', function*() { | |
| var nbArticles = yield night.evaluate(function() { | |
| return document.querySelectorAll('.blog-index h1').length; | |
| }); | |
| expect(nbArticles).to.equal(5); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment