Skip to content
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

Test at the end of Section 4 does not run #24

Open
mullaney opened this issue Apr 17, 2021 · 0 comments
Open

Test at the end of Section 4 does not run #24

mullaney opened this issue Apr 17, 2021 · 0 comments

Comments

@mullaney
Copy link

I have been working my way through this tutorial and really enjoying it. However, I've run into a problem testing. At the end of section 4, here is the state of my code: https://github.com/mullaney/nexus-js-tutorial/tree/28ac581142ac2f49ac46d3769e7810fc13ffb82b

I believe I followed all the instructions in section 4, however, I get the following error when I run npm run test:

{17:27}[ruby-3.0.0]‹node-15.4.0›~/Code/nexus-tutorial:main ✗ ➭ npm run test 
> [email protected] test
> npm run generate && jest


> [email protected] generate
> ts-node --transpile-only api/schema

 FAIL  tests/Post.test.ts
  ✕ ensures that a draft can be created and published (45 ms)

  ● ensures that a draft can be created and published

    called start() with surprising state started

      at ApolloServer.<anonymous> (node_modules/apollo-server-core/src/ApolloServer.ts:510:13)
      at node_modules/apollo-server-core/dist/ApolloServer.js:8:71
      at Object.<anonymous>.__awaiter (node_modules/apollo-server-core/dist/ApolloServer.js:4:12)
      at ApolloServer._start (node_modules/apollo-server-core/dist/ApolloServer.js:226:16)
      at ApolloServer.<anonymous> (node_modules/apollo-server/src/index.ts:108:16)
      at node_modules/apollo-server/dist/index.js:18:71

  ● ensures that a draft can be created and published

    TypeError: Cannot read property 'request' of undefined

       5 | it('ensures that a draft can be created and published', async () => {
       6 |   // Create a new draft
    >  7 |   const draftResult = await ctx.client.request(`
         |                                        ^
       8 |     mutation {
       9 |       createDraft(title: "Nexus", body: "...") {
      10 |         id

      at Object.<anonymous> (tests/Post.test.ts:7:40)

  console.log
    🚀 Server ready at http://localhost:4000/

      at api/server.ts:8:11

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.622 s, estimated 1 s
Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

The function createTestContext doesn't seem to be assigning a value to the client key as it's supposed to. Can someone offer me any help with how to get unstuck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant