How would we exactly test a resolver in nest js wi...
# support-questions
n
How would we exactly test a resolver in nest js with
session: Session
guard ?
r
Is this question about how to test your api which is guarded with our supertokens session?
@nikolaiavich
n
Yes
Not from postman tho
If I just follow convention of testing with nest js
To run the spec
r
Right. Which recipe are you using?
n
Just sign in email
Simple
I followed the nest js guide on super tokens
It’s working great
Just need to find a strategy to run my integration tests
r
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
n
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 ?
r
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.
t
@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
r
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.
t
OK, I'll checkout the docs and LYK if I'm still stuck. Thank you
r
Cool!