I'm using nightmare js to log into a site that sets a token in local storage. However, any future tests I run the user is already logged in. I'm guessing the local storage wasn't cleared. Is there any way to do this? My code in test.js
require('mocha-generators').install();
var Nightmare = require('nightmare');
var expect = require('chai').expect;
describe('test login', function() {
var nightmare = Nightmare({show: true})
after(function*() {
yield nightmare.end();
})
it('should login given right credentials', function*() {
this.timeout(50000);
console.log("running test");
var link = yield nightmare
.goto('http://127.0.0.1:3000/login')
.wait(1000)
.type('.email-field', '[email protected]')
.type('.password-field', 'password')
.click('.login button')
.wait(1000)
});
})
I run the test using: mocha
the test runs fine and closes. However when I run again the user starts off as logged in. Is there anyway to clear the cache or local storage in nightmarejs?
Electron has a way to clear session info via session.clearCache
(http://electron.atom.io/docs/v0.32.0/api/session/) but I don't know how to access the session object from nightmare.