Open kwokwilliam opened 6 years ago
Depending on the code, I may modify implementations to use dependency injections, so we can mock dependencies using jest.
Very seamless to use. This is the code for one test, and it's very straightforward to use. getOrderedConcepts()
is a function in wrapper
which is defined as a shallow(<WorldView />)
.
test('getOrderedConcepts contains only concepts in ConceptAbbreviations', () => {
const concepts = wrapper.instance().getOrderedConcepts();
concepts.forEach((concept) => {
expect(g[concept.name] !== undefined).toBe(true);
});
});
Added a CSS proxy because tests were crashing when trying to import objects with a CSS import at the top.
https://github.com/facebook/jest/issues/3094#issuecomment-385164816
Wrote guide a couple days ago for writing unit tests with Enzyme https://github.com/codeandcognition/koconut/blob/summer2018-master/docs/jest.md
Fix existing unit tests with new router change
test suite exists in src/tests, but they're out of date and incomplete
I have been looking into writing unit tests for React components.
It's done using a library called Enzyme, created by Airbnb (http://airbnb.io/enzyme/).
I'll start writing a few tests. I've never really wrote any unit tests before, so this'll be new. I'm sure it'll be very useful in the future for expansion.