Skip to content
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

Creating multiple app instances causes spec read to be empty #81

Closed
claabs opened this issue Oct 21, 2019 · 4 comments
Closed

Creating multiple app instances causes spec read to be empty #81

claabs opened this issue Oct 21, 2019 · 4 comments

Comments

@claabs
Copy link

claabs commented Oct 21, 2019

While writing unit tests for an express app, I kept seeing the error version missing from OpenAPI specification when creating multiple Express app instances within one Jest test file.

After some debugging, it looks like the root cause is loadSpecFile not throwing an error when performing require(absolutePath). This returns an object just containing __proto__, which lets it past all the null checks until it hits the version missing error.

How to reproduce

Just creating multiple app instances in index.js didn't seem to cause the bug. It may have something to do with how Jest sets up its tests. Using jest --runInBand to run the tests in series doesn't fix this.

@cdimascio
Copy link
Owner

Thanks for the issue @charlocharlie. The reproducible project is much appreciated. will have a look

@cdimascio
Copy link
Owner

I think i see the issue, should have a fix soon

cdimascio added a commit that referenced this issue Oct 22, 2019
* add type definitions

* add types

* fix spec loader

* increment version
@cdimascio
Copy link
Owner

@charlocharlie, please give v2.8.1 a try. it should fix the issue described. thanks!

@claabs
Copy link
Author

claabs commented Oct 22, 2019

Works for me now!

I'm curious what the root issue is. Maybe a file lock issue with require()?

Anyway, thanks for the quick turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants