Comments (5)
The initialize(app, cfg)
function is asyncronous in v3.0.0, which may be the source of the problem. Are you using async/await to wait for the initialize promise to fulfill? I don't have much experience working with jest but with mocha for unit testing, take a look to OAS Tools tests, they may be similar to what you are trying to accomplish.
from oas-tools.
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
- Download and extract the project
- Run 'npm install' command
- To start server run: make server
- To execute unit test cases run: make test
Project ZIP
repro-server.zip:
Observation: The test cases will execute successfully but the Test Suit will fail because of the error:
● 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)
from oas-tools.
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.
from oas-tools.
@vineetbro did you find any solution or work arounds for this issue?
from oas-tools.
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
from oas-tools.
Related Issues (20)
- [BUG] server property in swagger file no longer working HOT 9
- Add a way for controllers to handle async exceptions HOT 1
- How to use http query params with oas tools? HOT 3
- @oas-tools/core typescript support HOT 9
- [Suggestion] Change middleware chain order (Swagger UI not working) HOT 4
- [BUG] Dynamic routes have higher priority over static routes HOT 6
- [BUG] oas tool 3.0 fail to treat optional field in schema as option. HOT 9
- [BUG] V3 Not Backwards Compatible with V2 JSON Specification File Code HOT 1
- [BUG] Cannot convert undefined or null to object oas param file has issue HOT 2
- [BUG] File spec loading error in legacy project HOT 2
- oas tools module import issue when doing tests with jest. HOT 9
- Align js-yaml version with @oas-tools/commons HOT 1
- [BUG] JSON double-encoding when using res.json() and validator.responseValidation HOT 3
- [BUG] oneof yaml specification is not valid json HOT 1
- [Question]: Controller & Service file naming convention HOT 2
- [SUGGESTION] Problem with default exports "Controller X does not have method Y" HOT 1
- [BUG] customHandler for errors is not working as expected HOT 2
- Basepath is removed when calling any endpoint on google cloud functions. HOT 1
- [SUGESTION] Add support for mutualTLS security handler HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oas-tools.