testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.25k stars 460 forks source link

when running vitest(using react-testing-library-dom) in git action, action exceeded the maximum execution time of xx minutes #1299

Closed JayKim88 closed 1 month ago

JayKim88 commented 2 months ago

Relevant code or config:

// error occurs in a code using synchronous method to find an element.
it('~~~~', () => {
...
 await userEvent.click(totalCheckBoxInTable); // this makes changes in UI

const combineBtn = screen.getAllByText('합포장')[0]; // here, cannot find element in git action ending up with spending whole testing time with fail.
...
})

What you did:

In git action, it fails with the comment as "The job running on runner GitHub Actions XX has exceeded the maximum execution time of XX minutes."

As shown in the reproduction image, after combineOrders.test.tsx is passed, and it is stuck in the next test spending the whole test time ending up with test fail.

After testing this, I found that this error occurs in case that test tries to find a element by synchronous method such as getByText, getBy-. In local environment, it occurs error as intended if not found. If I replace these methods with asynchronous method like findby-, it works well locally and in git action.

What happened:

git-action-error-image

Reproduction:

Problem description:

Explained in What you did.

Suggested solution:

I haven't found a solution for it. Are there anybody who experienced this case ? I hope to know why this happens and how to fix it accordingly. I expect it must make error and fail as soon as it's impossible to find a target element.

Thank you all !

(By any chance, if it should be posted as Support Question, please let me know🙏)

github-actions[bot] commented 2 months ago

Uh oh! @JayKim88, the image you shared is missing helpful alt text. Check your issue body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

MatanBobi commented 2 months ago

Hi @JayKim88, thanks for opening this. Unfortunately this issue doesn't have enough for us to start investigating. Usually, getAllBy queries throw an error when elements can't be found so I highly don't think that's the command causing the issue.

Can you please share a minimal reproduction of this issue using our template?

Thanks.

JayKim88 commented 2 months ago

@MatanBobi Thank you for your reply. The error takes place in git action when i try to push a PR(But locally, it works well.), thus, by using the template as you kindly suggested, can I make reproduction of git action as well? Or is it enough for you to get a part of codes like below? also i'm able to provide you with a short video showing the error.

...
on:
  pull_request:
    branches:
      - staging
...
jobs:
            check_and_test:
              timeout-minutes: 10
              runs-on: ubuntu-latest
              steps:
                ...
                - name: Codegen and check type and test code
                  run: |
                    export NODE_OPTIONS="--max-old-space-size=4096"
                    pnpm i --frozen-lockfile
                    pnpm tsc --noEmit
                    pnpm test run // this is 
                    pnpm codegen

Thank you..!

MatanBobi commented 2 months ago

You can create a repo based on the template I've added and define the github action there :)

JayKim88 commented 2 months ago

You can create a repo based on the template I've added and define the github action there :)

okay..! Will create one and share accordingly~.

JayKim88 commented 2 months ago

You can create a repo based on the template I've added and define the github action there :)

okay..! Will create one and share accordingly~.

@MatanBobi I've tried and realized that I cannot apply the complexity of our product's code to the demo thus impossible to reproduce the error.

MatanBobi commented 1 month ago

Unfortunately, without a proper reproduction we won't be able to investigate and try to assist here. I'm closing this one as there's no actionable work item for us. If you will find a way to reproduce this, please feel free to re-open this and share the reproduction. We'd love to help.