OpenAPITools / OpenAPITools/openapi-generator
[BUG] `Exceeded timeout of 5000 ms for a test` error in jest
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Hi, I am facing a very weird behavior for the code that is generated based on my API, it is working for the most part except that when I make another HTTP call to an external API (e.g. http://localhost:9011) with fetch and then make my Ajax call with the generated code it stucks and when I comment that first http call it does not (this test suit).
Please note that the first http call is taking only a mere 193ms, it is not even a second to get the expected result. So I am completely lost. And that is why I thought of it as a bug and I hope I am not alone on that conclusion.
openapi-generator version
7.5.0
OpenAPI declaration file content or url
Generation Details
- Clone the repo
- Install deps:
npm ci npx nx test:e2e:docker backend-e2e- Wait for the configuration and bootstraping app to complete (if for any reason you got an error before tests start to run please reexcute the command)
- Check you terminal and see the error
FAIL backend-e2e apps/backend-e2e/src/auth/auth-business.e2e-spec.ts (7.827 s)
● Console
console.log
<STUCK>
at src/auth/auth-business.e2e-spec.ts:204:15
● Auth -- business › POST /auth/refresh › should refresh tokens
thrown: "Exceeded timeout of 5000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."
196 |
197 | describe('POST /auth/refresh', () => {
> 198 | it('should refresh tokens', async () => {
| ^
199 | const tempUser = getTempUser();
200 | const authenticationResult = await login({
201 | username: tempUser.email,
at src/auth/auth-business.e2e-spec.ts:198:5
at src/auth/auth-business.e2e-spec.ts:197:3
at Object.<anonymous> (src/auth/auth-business.e2e-spec.ts:19:1)
PASS backend-e2e apps/backend-e2e/src/app/app.e2e-spec.ts
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 39 passed, 40 total
Snapshots: 0 total
Time: 11.904 s
Ran all test suites.
Warning: command "NODE_ENV=test jest --config apps/backend-e2e/jest-e2e.config.ts" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NX Ran target test:e2e for project backend-e2e (14s)
✖ 1/1 failed
✔ 0/1 succeeded [0 read from cache]
Steps to reproduce
Explained in the previous section.
Related issues/PRs
Could not find any.
Suggest a fix
Axios/jest should send the request like normal without caring that I am making a separate Ajax call with fetch just how it does work with other test suits. Here is another test suit that passes without any error while making same Ajax call before sending a request with the generated code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/backend-e2e/src/auth/auth-business.e2e-spec.ts around lines 151 and 198, then review the linked openApi.json. Run npx nx test:e2e:docker backend-e2e and compare the passing and timing-out cases, focusing on the fetch call before the generated API request. Done means the refresh-token test completes without the Jest timeout while retaining the external call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100