Created
June 8, 2016 08:51
-
-
Save rdohms/9b659aba018fdefd20682f2df067970c to your computer and use it in GitHub Desktop.
Writing tests
This file contains 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
require('mocha-generators').install(); | |
var path = require('path'); | |
var Nightmare = require('nightmare'); | |
var expect = require('chai').expect; | |
describe('AmsterdamPHP Raffler', function () { | |
this.timeout(15000); // Set timeout to 15 seconds, instead of the original 2 seconds | |
var url = 'http://localhost:8080', | |
nightmare; | |
beforeEach(function *() { | |
nightmare = Nightmare({ | |
show: true | |
}); | |
}); | |
afterEach(function *() { | |
yield nightmare.end(); | |
}); | |
describe('Event List', function () { | |
it('should show a list of current/past events', function *() { | |
var x; | |
var result = yield nightmare | |
.goto(url) | |
.evaluate(function (x) { | |
//return document.querySelectorAll('ul.meetups > li').length; // evaluates to 95 | |
return document.querySelectorAll('ul.meetups > li'); | |
}); | |
expect(result.length).to.be.above(1); // length undefined | |
}); | |
}); | |
}); |
so for reference: evaluate
serializes return into json, hence all properties go bye bye.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You also need * after the function keyword when yield is called inside the function block