How to call a promisified function in-page with Nightmare/mocha/chai
Two important things to keep in mind:
- You have to return from inside the "it" function (boldfaced below)
- You need to list parameters to evaluate three times, the third time as a list of parameters after the function argument to evaluate (also boldfaced below)
it(`Keystretching ${clearTextPassword} with ${hexNonce} with current params should give ${theExpectedDerivedKey}`, function () { this.timeout('10s') return Nm() .goto(`file://${__dirname}/../index.html`) .evaluate((clearTextPassword, hexNonce, keyStretchFactor) => { return stretch(clearTextPassword, hexNonce, keyStretchFactor) }, clearTextPassword, hexNonce, keyStretchFactor) .end() .then(res => expect(res.derivedKey).to.equal(theExpectedDerivedKey)) });