Passport.js stub for testing.
Want to see pretty graphs? Log in now!
npm install passport-stub
|9||downloads in the last day|
|246||downloads in the last week|
|1 199||downloads in the last month|
|Last Published By|
|Version||0.2.1 last updated a month ago|
|Keywords||passport, stub, test|
Written with the idea of being simple to use.
passportStub = require 'passport-stub' request = require 'supertest' app = require '../app' passportStub.install app req = request app describe 'GET /admin', -> it 'responds with 401 if not logged in', (done) -> req.get('/admin').expect(401).end done it 'responds with 200 when logged in', (done) -> passportStub.login username: 'john.doe' req.get('/admin').expect(200).end done
The user you log in with can be whatever user your app would expect to deal with. It could be a mongoose model, for example.
Although I didn't use, I've included a few other functions that might be useful. The code itself is pretty simple, so take a look at it.
This is licensed under the feel-free-to-do-whatever-you-want-to-do license.