-
Notifications
You must be signed in to change notification settings - Fork 276
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
Nexus Tutorial Part 4. Testing your API fails npm run test #878
Comments
Continued on to part 6. Testing with Prisma, and basically got the same terminal response back after running npm run test command. I have never used jest before. Just learning how to use these tools, and I have no idea where to start to fix this issue. |
me either. |
Hi @raleigh9123 👋🏾 Thank you for creating this issue. I tested it locally and ran into the same issue.
You are right, this is one of the fixes to the tutorial. I updated the tutorial recently and I have a hunch it broke the tests. Update your import { ApolloServer } from 'apollo-server'
import { schema } from './schema'
import { context } from './context'
export const server = new ApolloServer({ schema, context }) Create import { server } from "./server";
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`)
}) Lastly, update your "scripts": {
"dev": "ts-node-dev --transpile-only --no-notify api/app.ts",
"build": "tsc",
"generate": "ts-node --transpile-only api/schema",
"test": "npm run generate && jest"
}, Re-run your tests and let me know if you run into any issues. 🙂 We'll update the tutorial soon fixing this error. |
This did solve the problem I encountered! Thank you. When running the command again, I did receive an error that Jest could not find the node module "Prettier" Installing prettier as a dev dependency cleared this error and the test runs successfully. |
Going to keep this open until you've updated the tutorial @ruheni, thanks! |
I'm working through the Nexus tutorial and encounter an error when running the command "npm run test". I have included a screenshot of the terminal output of the command and can't seem to figure out the problem.
I have the following versions installed in my package.json
Perhaps an important note, the tutorial also misses including an export statement in the server.ts file located in /api/server.ts.
The export statement was not included in any of the previous tutorial chapters but is imported as a module in tests/__helper.ts on line 4.
The text was updated successfully, but these errors were encountered: