Recently, I encountered an issue in Travis CI and my Aurelia application which uses Jest for the tests suite. I erroneously copied some older configuration code for Jest and used it in my Jest configuration, assuming it would work.
This error took a while to isolate and resolve. It was out of pure desperate that I accidentally discovered the fix. If I made the mistake, it is possible that you might as well. Does this sound familiar to you?
Tests were working locally. Running Jest would run my tests and they would all pass, giving a nice 0 code, happy days. Pushing my changes up causing my Travis CI build to automatically run would result in an error. The error looked like the following (this is the actual error):
One thing you will notice is my
testRegex is saying there are 3 matches, which is correct. I have three test files which run and work locally without issue. I tried modifying my
testRegex I tried changing the location of my tests, nothing worked. Then I noticed I had
testPathIgnorePatterns defined in my Jest configuration (part of my older config).
This is my actual code. I was ignoring my
sample directories from testing. It turns out defining this locally causes no problem, but causes Travis CI to fail. At first, I was confused, why is this breaking Travis CI.
Then it dawned on me. It’s the fact I am using some outdated configuration option, the issue is the path in which tests and code are run inside of the virtualised Travis CI environment.
Can you spot the issue? The path is
/home/travis/build/steem-engine-exchange/steem-engine-dex what is contained within this path? A folder named
buildwhich is located under
/home/travis ignoring build causes this to get matched and thus, it breaks the tests from running.
My innocent ignore rule was being triggered only in Travis CI, not locally because locally my files are run from my home directory and not within a build directory.