Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
兼容高版本环境下的测试用例
高版本环境下:
Node.js: 10.15.2
mocha: 6.1.4
should: 13.2.3
supertest: 4.0.2
express: 4.17.0
运行测试用例会占用3000端口,可能导致:
1.app已运行的情况下,会报端口已被占用的错误
2.app没有运行,测试用例运行后没有退出,继续监听端口
解决方法:
根据module.parent判断是否为运行测试用例,是的话则不监听端口