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:
- Running npm install locally, some packages were indeed modified, but it had no effect on the test
- Checked node versions on local and on env B. Changing local version to exactly the one used on env B (I use nvm, node version is v12 LTS) had no effect on the test.
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.