passport-next / passport

Simple, unobtrusive authentication for Node.js.
MIT License
36 stars 5 forks source link

Passport Mock #2

Closed guyellis closed 6 years ago

guyellis commented 6 years ago

This is a discussion topic, not an issue.

First off - thanks so much @rwky for forking these repos into .../passport-next/... and publishing them!

I was wondering if this passport-next org would be the right place to create and publish a passport-mock module to help with testing?

I found https://github.com/shake-apps/passport-mocked but that seems to be stale.

Thoughts?

rwky commented 6 years ago

That's a good idea! I could probably do with using a module like that myself. Leave it with me.

guyellis commented 6 years ago

Thanks so much @rwky

Looking at that passport-mocked module I'm not a fan of how the module is included in the production code and required based on NODE_ENV. I think that the mocks should stay out of prod code and be swapped in during testing.

What test framework do you use? My favorite is jest. With the jest syntax I'd love to be able to do something like:

const mockPassport = require('@passport-next/passport-mock');
jest.mock('passport', () => mockPassport);
rwky commented 6 years ago

Never used jest normally we use mocha/chai never used jest. As for the NODE_ENV I can see that being a useful method but not a required one. For test suites you'd just require the mock module instead of whatever module you'd use during live and that should do the trick.

guyellis commented 6 years ago

This is complete.