You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.
I am looking to set up a full integration test of an API that is running on this library and the other (potentially outdated swagger-express-mw) library. I found a bunch of misc threads on GH (#495) regarding testing but have not found any comprehensive examples of how to use supertest with this library.
Reading through some of these threads it seems that one of the issues is that you must wait for swaggerMw to initialize and then export your app async so you can use it in tests. I solved this by creating a wrapper in the form of:
asyncfunctioninit(){returnnewPromise((resolve,reject)=>{SwaggerExpress.create(swaggerConfig,function(err,swaggerExpress){// set up 100 lines of various middleware with app.use()// thenresolve(app)}
I export this function and then wanted to use it in my jest test like so:
constinit=require('../../../src/app')describe('foo',()=>{it('bar',()=>{// use initinit().then(app=>{// use app in supertestrequest(app).... // do some stuff})})})
However, it seems that what happens is that the second I require the app (const init = require('../../../src/app')), my entire test crashes with
Hi,
I am looking to set up a full integration test of an API that is running on this library and the other (potentially outdated swagger-express-mw) library. I found a bunch of misc threads on GH (#495) regarding testing but have not found any comprehensive examples of how to use supertest with this library.
Reading through some of these threads it seems that one of the issues is that you must wait for swaggerMw to initialize and then export your app async so you can use it in tests. I solved this by creating a wrapper in the form of:
I export this function and then wanted to use it in my jest test like so:
However, it seems that what happens is that the second I require the app (
const init = require('../../../src/app')
), my entire test crashes withAnd I get an error about
Cannot find module '/myapp/src/api/fittings/swagger_router' from 'node_modules/bagpipes/lib/fittingTypes/user.js'
Any ideas what might be causing this? I am not sure what
fittingTypes
anduser.js
is or where they come from...The text was updated successfully, but these errors were encountered: