Giter Site home page Giter Site logo

While running oas-tools with jest for unit test cases it throws error: 'request for ./middleware/index.js is not yet fulfilled' about oas-tools HOT 5 CLOSED

vineetbro avatar vineetbro commented on June 16, 2024
While running oas-tools with jest for unit test cases it throws error: 'request for ./middleware/index.js is not yet fulfilled'

from oas-tools.

Comments (5)

alesancor1 avatar alesancor1 commented on June 16, 2024

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.

vineetbro avatar vineetbro commented on June 16, 2024

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

  1. Download and extract the project
  2. Run 'npm install' command
  3. To start server run: make server
  4. 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.

alesancor1 avatar alesancor1 commented on June 16, 2024

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.

johonIngka avatar johonIngka commented on June 16, 2024

@vineetbro did you find any solution or work arounds for this issue?

from oas-tools.

vineetbro avatar vineetbro commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.