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

Tests fail on CI #270

Closed
6 tasks done
wtchnm opened this issue Dec 22, 2021 · 5 comments
Closed
6 tasks done

Tests fail on CI #270

wtchnm opened this issue Dec 22, 2021 · 5 comments

Comments

@wtchnm
Copy link
Contributor

wtchnm commented Dec 22, 2021

Describe the bug

Hi! My tests are working fine locally but are failing on CI. Here are the GitHub Actions logs:

> vitest run --coverage


 RUN  /home/runner/work/Vitamin/Vitamin

 √ utils.ts > useMediaQuery > renders
 √ Fruit.tsx > <Fruit /> > renders
 √ Fruit.tsx > <Fruit /> > redirect to fruit details page on enter
 √ Fruit.tsx > <Fruit /> > redirect to photographer profile page on image attribute link click
 √ App.tsx > <App /> > renders
 √ Details.tsx > <Details /> > redirect to home screen if fruit is not found
 × LoadingOrError.tsx > <LoadingOrError /> > renders
   → Unable to find an element with the text: Loading.... 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.

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 × Details.tsx > <Details /> > renders
   → Unable to find role="link"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 × Gallery.tsx > <Gallery /> > renders
   → Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 × LoadingOrError.tsx > <LoadingOrError /> > renders with an error message
   → Unable to find an element with the text: Failed to fetch. 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.

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 × Details.tsx > <Details /> > renders with mobile resolution
   → Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 × Gallery.tsx > <Gallery /> > renders with mobile resolution
   → Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />

 Failed Tests 6 

 FAIL  LoadingOrError.tsx > <LoadingOrError /> > renders
Error: Unable to find an element with the text: Loading.... 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.

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
 ❯ src/components/__tests__/LoadingOrError.tsx:8:22

⎯⎯⎯⎯[1/6]⎯

 FAIL  LoadingOrError.tsx > <LoadingOrError /> > renders with an error message
Error: Unable to find an element with the text: Failed to fetch. 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.

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
⎯⎯⎯⎯[2/6]⎯
 ❯ src/components/__tests__/LoadingOrError.tsx:13:22


 FAIL  Details.tsx > <Details /> > renders
Error: Unable to find role="link"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
 ❯ src/pages/__tests__/Details.tsx:26:16

⎯⎯⎯⎯[3/6]⎯

 FAIL  Details.tsx > <Details /> > renders with mobile resolution
Error: Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
 ❯ src/pages/__tests__/Details.tsx:45:29

⎯⎯⎯⎯[4/6]⎯

 FAIL  Gallery.tsx > <Gallery /> > renders
Error: Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
⎯⎯⎯⎯[5/6]⎯
 ❯ src/pages/__tests__/Gallery.tsx:16:22


 FAIL  Gallery.tsx > <Gallery /> > renders with mobile resolution
Error: Unable to find role="img"

Ignored nodes: comments, <script />, <style />
<body />

Ignored nodes: comments, <script />, <style />
<body />
 ❯ waitForWrapper node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1276:25
    1274|   // create the error here so its stack trace is as close to the
    1275|   // calling code as possible
    1276|   var stackTraceError = new Error('STACK_TRACE_MESSAGE');
       |                         ^
    1277|   return getConfig().asyncWrapper(function () {
    1278|     return waitFor(callback, _extends({
 ❯ node_modules/.pnpm/@[email protected]/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1373:12
⎯⎯⎯⎯[6/6]⎯
 ❯ src/pages/__tests__/Gallery.tsx:26:22


Test Files  3 failed | 3 passed (6)
     Tests  6 failed | 6 passed (12)
      Time  9.14s (in thread 7.34s, 124.52%)

It looks like the DOM is not being rendered in some tests. Maybe I have to wait some time before making the assertions?

Reproduction

Repo: https://github.com/wtchnm/Vitamin/tree/feat/vitest
Action: https://github.com/wtchnm/Vitamin/runs/4607533559?check_suite_focus=true

System Info

System:
    OS: Linux 5.15 undefined
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 5.02 GB / 15.60 GB
    Container: Yes
    Shell: 3.3.1 - /usr/bin/fish
  Binaries:
    Node: 16.13.1 - /usr/bin/node
    Yarn: 1.22.15 - ~/.npm-global/bin/yarn
    npm: 8.3.0 - /usr/bin/npm
  Browsers:
    Brave Browser: 96.1.33.106
    Firefox: 95.0.2
  npmPackages:
    @vitejs/plugin-react: 1.1.3 => 1.1.3 
    vite: 2.7.6 => 2.7.6 
    vitest: 0.0.107 => 0.0.107

Used Package Manager

pnpm

Logs

No response

Validations

@wtchnm
Copy link
Contributor Author

wtchnm commented Dec 22, 2021

I get the same errors locally if I disable tinypool. Interesting.

@wtchnm
Copy link
Contributor Author

wtchnm commented Dec 24, 2021

It's fixed, thanks!

@wtchnm wtchnm closed this as completed Dec 24, 2021
@vjee
Copy link

vjee commented Apr 28, 2022

@wtchnm Hi, what did you do to solve this issue?
I'm running into the same thing. Most of the times CI passes but sometimes I get the same errors as you did.

@wtchnm
Copy link
Contributor Author

wtchnm commented Apr 28, 2022

Hi @vjee! I just updated vitest. I think it has something to do with concurrency as at that time I got the same errors locally disabling tinypool.

@vjee
Copy link

vjee commented Apr 28, 2022

@wtchnm When I run vitest with --no-threads locally, I can reproduce the issue too. But unfortunately I'm already on the latest version :).

Thanks for the repy. It looks like I have some more debugging to do.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants