entria / entria-fullstack

Monorepo Playground with GraphQL, React, React Native, Relay Modern, TypeScript and Jest
MIT License
497 stars 73 forks source link

Fix "should render success UserList" test #142

Closed lucas-mdiniz closed 8 months ago

lucas-mdiniz commented 3 years ago

As mentioned at #140, one test is not passing.

The test is:

should render success UserList

It seems to be some problem on mocking the payload ( MockPayloadGenerator) but I'm not sure yet, it needs more debugging.

daniloab commented 3 years ago

Paste here the stack trace

lucas-mdiniz commented 3 years ago

Here is the stack trace:

  ● <UserList /> › should render success UserList

    TestingLibraryElementError: Unable to find an element with the text: ID: Q2xpZW50OjE=. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

    <body>
      <div>
        <div>
          <a
            class="UserList__Card-sc-1uc7hyr-0 cHjsxG"
          >
            <span>
              ID: 
              &lt;User-mock-id-1&gt;
            </span>
            <span>
              User: 
              &lt;mock-value-for-field-"name"&gt;
            </span>
            <span>
              Email: 
              &lt;mock-value-for-field-"email"&gt;
            </span>
          </a>
        </div>
      </div>
    </body>

      78 |     });
      79 | 
    > 80 |     expect(getByText('ID: Q2xpZW50OjE=')).toBeTruthy();
         |            ^
      81 |     expect(getByText('User: Adhis Yudha')).toBeTruthy();
      82 |     expect(getByText('Email: example.example@gmail.com')).toBeTruthy();
      83 | 

      at Object.getElementError (../../node_modules/@testing-library/dom/dist/config.js:37:19)
      at args (../../node_modules/@testing-library/dom/dist/query-helpers.js:90:38)
      at args (../../node_modules/@testing-library/dom/dist/query-helpers.js:62:17)
      at getByText (../../node_modules/@testing-library/dom/dist/query-helpers.js:106:19)
      at _callee2$ (src/__tests__/UserList.spec.tsx:80:12)
      at tryCatch (../../node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (../../node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.next (../../node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (../../node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (../../node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at ../../node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
      at Object.<anonymous> (../../node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)