Nexus Tutorial Part 4. Testing your API fails npm run test
See original GitHub issueI’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
"dependencies": {
"apollo-server": "^2.22.2",
"graphql": "^15.5.0",
"nexus": "^1.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.22",
"get-port": "^5.1.1",
"graphql-request": "^3.4.0",
"jest": "^26.6.3",
"ts-jest": "^26.5.4",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.3"
}

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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
4. Testing your API - GraphQL Nexus
System testing means tests that will run operations against your API just ... During this tutorial, you'll use the Jest testing framework to...
Read more >start-server-and-test - npm
Start using start-server-and-test in your project by running `npm i ... then runs test command; when the tests end, shuts down server. NPM....
Read more >Fullstack part4 | Testing the backend
Let's use the supertest package to help us write our tests for testing the API. We will install the package as a development...
Read more >Build a Node.js and React app with npm - Jenkins
This tutorial shows you how to use Jenkins to orchestrate building a simple Node.js and React application with the Node Package Manager (npm)....
Read more >Getting Started - Node Tap
A command-line interface for running tests and reporting on their success or failure. Support for test-coverage, including coverage of child processes spawned ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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
server.ts
file to resemble this:Create
app.ts
file in the api folder and importserver
as follows:Lastly, update your
package.json
scripts to point thedev
script toapp.ts
:Re-run your tests and let me know if you run into any issues. 🙂
We’ll update the tutorial soon fixing this error.