greatly improve travis-ci pass rate #6816
Merged
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.
1. Fix
model: querying: with previously existing null values in the db
This test fails frequently. You can see it in almost every travis build that fails.
Like this one: https://travis-ci.org/Automattic/mongoose/jobs/412335127
Explanation
The description of mocha output is misleading. If you inspect the error stacks, you can find that the actual assertion error is at
test/model.querying.test.js:1983:16
so the actual test case that fails ismodel: querying: with conditionals
I guess it's because the error is thrown in callback so mocha fail to recognize the correct test case. I think tests need to be refactored to avoid throwing error in async callback. We should use
done(err)
instead to let mocha know where the error is.There are 10 sub-tests in this test case. So
pending
tests number should be10
instead of9
.The incorrect
pending
value may lead toTest
collection being removed too early and trigger this error. That's why travis-ci often fail on this test becausepending
value is wrong.2. Fix collection name conflict in
model: querying:
testsFix build failure like this: https://travis-ci.org/Automattic/mongoose/jobs/412108300
Explanation
Simply move the generation of random collection name from
before
tobeforeEach
to guarantee unique collection name is used.3. Fix
QueryCursor#eachAsync() parallelization
andaggregate: cursor() eachAsync with options (parallel)
Fix build failure like this: https://travis-ci.org/Automattic/mongoose/jobs/412101075
Explanation
If
setTimeout
is so accurate that delay exactly 100ms, this test will fail.