I have a peculiar situation that has been occurring. I have been testing my React application with Mocha, Enzyme, Chai, and nyc.
Locally on my machine everything works perfectly of my 6 tests that I have all 6 pass. 2 of those tests are tests that call mount from enzyme:
it('Should contain my name in the text', () => {
const context = { router: { } };
const footer = mount(<Footer />, context);
console.log(footer);
expect(footer.text()).to.contain('Myname');
});
it('Should contain a link to the copyright page', () => {
const footer = mount(<Footer />);
expect(footer.find('a').prop('href')).to.equal('/Copyright');
});
On my local machine these run fine. When my tests get run on Travis-ci, these two tests fail for the following reason:
Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
in Link (created by Unknown)
in footer (created by Unknown)
in Unknown (created by Unknown)
in Unknown
I am very perplexed as to why this is not failing on my local machine if this is the case. I would love any help that I could get to try to figure this out.
The version of software I am currently using:
"chai": "^3.5.0",
"enzyme": "^2.6.0",
"mocha": "^3.1.0",
"react-dom": "15.4.0",
"react": "15.4.0",
"react-router": "next" #this is version v4