# How can I bypass auth to test my routes with sinon

**URL:** <https://community.auth0.com/t/how-can-i-bypass-auth-to-test-my-routes-with-sinon/92908>\
**Category:** Get Help\
**Tags:** testing\
**Created:** [October 21, 2022, 9:10pm UTC](https://community.auth0.com/t/how-can-i-bypass-auth-to-test-my-routes-with-sinon/92908 "2022-10-21T21:10:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstart](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstart/32/33316_2.png) [@mstart](https://community.auth0.com/u/mstart)\
**Post date:** [October 21, 2022, 9:10pm UTC](https://community.auth0.com/t/how-can-i-bypass-auth-to-test-my-routes-with-sinon/92908/1 "2022-10-21T21:10:14Z")

</div>

Not sure if this is a duplicate but couldn’t find anything.

I need to test a bunch of routes using mocha and supertest, however every route is locked down with the following:

const { requiresAuth, auth } = require(“express-openid-connect”);

const AUTH\_CONFIG = {  
authRequired: false,  
auth0Logout: true,  
baseURL:  
secret:  
clientID:  
issuerBaseURL: ,  
routes: {  
callback: “/auth0/callback”,  
postLogoutRedirect: “/login”,  
},  
};

app.use(auth(AUTH\_CONFIG));

app.use(  
‘/route’  
requiresAuth(),  
);

Is there a way I can stub a response for requiresAuth() so i can bypass for testing? If not, how can I get around this issue?

Thank You

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 21, 2022, 11:54pm UTC](https://community.auth0.com/t/how-can-i-bypass-auth-to-test-my-routes-with-sinon/92908/2 "2022-10-21T23:54:38Z")

</div>

Hey there @mstart welcome to the community!

Have you considered just using a test user to go through the flow?

> **[Test Applications Locally](https://auth0.com/docs/get-started/applications/work-with-auth0-locally)**
>
> Learn how to develop and test Auth0 applications.

Let us know!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 22, 2022, 12:01am UTC](https://community.auth0.com/t/how-can-i-bypass-auth-to-test-my-routes-with-sinon/92908/4 "2022-12-22T00:01:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
