I'm trying to use nightmareJS for doing some tests. Therefore I installed nightmare, mocha and chai globally
$ npm install -g nightmare mocha chai
Now I'm running the test script, but it gives me the error:
$ node e2e.js
module.js:327
throw err;
^
Error: Cannot find module 'nightmare'
If I install nightmare locally I'm getting the error
$ node e2e.js
/path/e2e.js:4
describe('test duckduckgo search results', function() {
^
ReferenceError: describe is not defined
e2e.js
var Nightmare = require('nightmare'),
expect = require('chai').expect // jshint ignore:line
describe('test duckduckgo search results', function() {
it('should find the nightmare github link first', function(done) {
var nightmare = Nightmare()
nightmare
.goto('https://duckduckgo.com')
.type('#search_form_input_homepage', 'github nightmare')
.click('#search_button_homepage')
.wait('#zero_click_wrapper .c-info__title a')
.evaluate(function() {
return document.querySelector('#zero_click_wrapper .c-info__title a').href
})
.end()
.then(function(link) {
expect(link).to.equal('https://github.com/segmentio/nightmare')
done()
})
})
})
via user3142695
No comments:
Post a Comment