I have a Mocha integration test as a part of a Node test script. After merging the new functionality, the test passed consistently on a release branch locally. After merging the code into master and attempting to build a Jenkins job on a different environment (let's call it env B), the very same test consistently fails in that environment.
The test contains a single Chai shallowDeepEqual assertion . The test fails because (for some reason) expected and actual results have items in a different order. Obviously, editing the assertion is not an option.
What I've tried:
After some digging, I found that the problem could be related to Jenkins caching , but I found no trivial way to force-clear cache before a build.
After npm install (1), I noticed that the package-lock.json file had a diff from the current branch. After committing and merging the diff, the Jenkins job is now passing.
I assume that tests were failing because Jenkins was using cached dependencies. After I committed the fresh version of package-lock.json , Jenkins might have noticed a dependency change and rebuild cache.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.