Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (24 sloc) 1.27 KB


The internal .then() method to Nightmare does not work precisely like native Promise .then(), instead always opting to take the success and rejection callback for the promise. This was probably done to make sure vo, co, and possibly mocha-generators would work nicely with Nightmare.

The side effect of this is minor, causing exceptions internal to .then() to behave differently to their Promise counterparts. Consider:

var Nightmare = require('nightmare');
var nightmare = Nightmare();
  .evaluate(function() {
    return document.title;
  .then(function(title) {
  }, function(err) {
    console.log('second argument error');

In an ordinary promise, the rejection argument would not get called, yet in Nightmare, it does.


Alter the .then() implementation to call .then(fulfill, reject) instead of .then(fulfill).catch(reject). As yet, PR is unsubmitted.


You can’t perform that action at this time.