You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like turtles! And nexus. I just went through most of the tutorial and am very impressed. The tutorial is great. Only the testing section is problematic for me.
FirstI am going to describe an issue that I solved already, and second another issue I couldn't solve. I would appreciate some help on this. I am also willing to send a PR for the documentation once I got it running.
1. (Solved) Error once I copy-pasted the tutorial code into my project:
This was solved by passing the prisma client aka db into graphqlTestContext.before as described below (look at the lines with the green checkmarks ✅):
exportfunctioncreateTestContext(): TestContext{letctx={}asTestContext;constgraphqlCtx=graphqlTestContext();constprismaCtx=prismaTestContext();beforeEach(async()=>{constdb=awaitprismaCtx.before();constclient=awaitgraphqlCtx.before(db);// ✅ Here... Object.assign(ctx,{
client,
db,});});afterEach(async()=>{awaitgraphqlCtx.after();awaitprismaCtx.after();});returnctx;}functiongraphqlTestContext(){letserverInstance: ServerInfo|null=null;return{asyncbefore(db: PrismaClient){// ✅ ...and hereconstport=awaitgetPort({port: makeRange(4000,6000)});serverInstance=awaitserver.listen({ port });// Close the Prisma Client connection when the Apollo Server is closedserverInstance.server.on("close",async()=>{db.$disconnect()});returnnewGraphQLClient(`http://localhost:${port}`);},asyncafter(){serverInstance?.server.close();},};}
I am actually not sure why we cant just close the db connection in prismaTestContext.after ?
2. Port 4000 already in use.
The tutorial works fine for just one test. Once you add more than one test, those fail with the following error listen EADDRINUSE address already in use :::4000
The tutorial code uses get-port to get an available code. After reading through get-code's github issues I tried the solution described here. Unfortunately without success. Can you give me a hint on how to run this setup with multiple test files and tests.
The text was updated successfully, but these errors were encountered:
I like turtles! And nexus. I just went through most of the tutorial and am very impressed. The tutorial is great. Only the testing section is problematic for me.
FirstI am going to describe an issue that I solved already, and second another issue I couldn't solve. I would appreciate some help on this. I am also willing to send a PR for the documentation once I got it running.
1. (Solved) Error once I copy-pasted the tutorial code into my project:
This was solved by passing the prisma client aka
db
intographqlTestContext.before
as described below (look at the lines with the green checkmarks ✅):I am actually not sure why we cant just close the db connection in
prismaTestContext.after
?2. Port 4000 already in use.
The tutorial works fine for just one test. Once you add more than one test, those fail with the following error
listen EADDRINUSE address already in use :::4000
The tutorial code uses get-port to get an available code. After reading through get-code's github issues I tried the solution described here. Unfortunately without success. Can you give me a hint on how to run this setup with multiple test files and tests.
The text was updated successfully, but these errors were encountered: