An enzyme that does not pass context to a component on Travis

I have a peculiar situation that has occurred. I tested the React app with Mocha, Enzyme, Chai and nyc.

Locally on my machine everything works fine with my 6 tests, I have all 6 passes. 2 of these tests are tests that cause attachment from the 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, everything is working fine. When my tests 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 puzzled by why this does not fail on my local machine, if so. I would like to help to try to understand this.

The version of software that 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 
+5
source share

Source: https://habr.com/ru/post/1261233/


All Articles