-
Notifications
You must be signed in to change notification settings - Fork 60
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
While running oas-tools with jest for unit test cases it throws error: 'request for ./middleware/index.js is not yet fulfilled' #342
Comments
The |
I have used the async/await to wait for initialization. The behaviour is such, with 'require(@oas-tools/core)' itself the error is thrown. I am providing a zip file of project where the error can be reproduced. Here are the instructions to run and test the project
Project ZIP Observation: The test cases will execute successfully but the Test Suit will fail because of the error: |
This seems to be an issue with jest itself and the way it deals with ESM packages (see the issue here), so there's not much that can be done at the moment. The core package will migrate to TS in the future and hopefully it will solve this problem due to the code being transpiled into CommonJS. For the time being, you could use mocha + c8 for coverage (I tested your repro-server using mocha and it works) or update to Node.js v18, which has an integrated testing library that I believe is pretty similar to jest. |
@vineetbro did you find any solution or work arounds for this issue? |
No, It is an issue with jest only. Right now I am using v2.2.2. The other option is to use mocha in place of jest |
Describe the bug
I am using oas-tools 3.0.0 for my server and jest 29.0.0 for unit test case. My server runs as expected but when I ran my unit test cases it throws the error: 'request for ./middleware/index.js' is not yet fulfilled' and all test cases started failing. When I tried with oas-tools: 2.2.2 it works totally fine.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The Oas must have initialized properly when running unit test cases using jest
Logs
2022-09-19T06:44:01.320Z - info: Specification file dereferenced
2022-09-19T06:44:01.402Z - info: Registered OASParams middleware
2022-09-19T06:44:01.403Z - info: Registered OASRequestValidator middleware
2022-09-19T06:44:01.403Z - info: Registered OASResponseValidator middleware
2022-09-19T06:44:01.403Z - info: Registered OASRouter middleware
2022-09-19T06:44:01.403Z - info: Registered OASSwagger middleware
2022-09-19T06:44:01.425Z - info: OAS Initialized successfully
● Test suite failed to run
request for './middleware/index.js' is not yet fulfilled
at Runtime.linkAndEvaluateModule (node_modules/jest-runtime/build/index.js:767:5)
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: