Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would someone write automated tests for their site that uses SuperTokens? #115

Open
rishabhpoddar opened this issue Nov 10, 2020 · 4 comments
Labels
question Further information is requested

Comments

@rishabhpoddar
Copy link
Contributor

  • For sessions
  • For login
  • Using postman
  • Using code
@rishabhpoddar rishabhpoddar added the question Further information is requested label Nov 10, 2020
@kant01ne
Copy link
Contributor

Backend

People will most likely not want to start a SuperTokens core server just to test their backend API.
We could potentially provide:

  • Turning on a flag in the SuperTokens.init function would put the node sdk in testing mode and would never require any core interaction.
  • mocking capabilities for signin / signup / logout from the NodeJS SDK, which emulates how the core behave
    • no password encryption, cleartext comparison with an in memory storage
  • Provide a method that returns working request headers for a given email:
  const authHeaders = SuperTokensMock.getAuthHeaders("[email protected]");
  const res = await fetch('/api/v1/users', {
     headers: {
        someHeaders,
        ...authHeaders
     }
  });
  • mocking capabilities for sessions from the NodeJS SDK, which emulates how the core behave

This approach allows developers to test their API easily without having troubles bypassing SuperTokens system. The downside is that it doesn't test if authentication/session management (/ permissions / roles in the future) work well with their system. Most likely, when using a 3rd party you want to trust them and not to implement redundant tests so that's fine.

Front End

In an end-to-end scenario that connects to a NodeJS backend, we would leverage the above which would be completely invisible to the front end.

@rishabhpoddar
Copy link
Contributor Author

Interesting idea. Will think about this for the next release.

@neongreen
Copy link

I'm developing a service that uses Supertokens (managed hosting) and I'm interested in this. What's the current best practice for writing end-to-end tests?

@rishabhpoddar
Copy link
Contributor Author

@neongreen the current way to do this is to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants