How would we exactly test a resolver in nest js wi...
# support-questions
How would we exactly test a resolver in nest js with
session: Session
guard ?
Is this question about how to test your api which is guarded with our supertokens session?
Not from postman tho
If I just follow convention of testing with nest js
To run the spec
Right. Which recipe are you using?
Just sign in email
I followed the nest js guide on super tokens
It’s working great
Just need to find a strategy to run my integration tests
You will need to setup the core for testing as well. You can run it without being connected to the db.
And then send a login request, which will create a session, and then take the session cookies and add them to your request
I see so I can run individual resolvers as conventionally recommended ?
Like e2e I can run is what your saying
couldn't i just mock the session interface in theory ? @rp ?
You could. You can override the session functions in session.init -> override.functions -> , and then override createNewSession, getSession etc etc.. to make it work
And in the getSession function, you could always just let it pass and return a session object similar to how you are doing above, but with the userId that you care about.
@rp Do you have any other resources on setting up testing? It'd be great if there was a step-by-step guide to testing, which outlined how to either run the core or mock the session functions. I've gotten ST to work in production, but that broke all of my integration tests in the process. It feels a bit overwhelming to have to figure out all the steps you outline
You can checkout how we do testing if you visit our backend SDK tests. Alternately, I’d be happy to walk you through it on a call. Unfortunately we don’t yet have docs for this yet.
OK, I'll checkout the docs and LYK if I'm still stuck. Thank you