I have a React Component that takes an array and iterates over each node, styling and rendering HTML elements based on the types found within the array. I have everything running properly and now I’m …
Tag: enzyme
SyntaxError: Unexpected token ‘
I am running tests with jest and enzyme in my React application, and while my simple sanity check test (2+2 expect 4) works, this error is thrown when I go to shallow render a component. It also …
Unit test with react hook fails
I don’t understand the result I get on this unit test. I expect the second check for textField.valid to be true and instead it returns false. Below is part of the component I’m testing against: export …
How to mock the useState hook implementation so that it actually changes the state during testing
I’m trying to test a component which renders two different sub-components when its internal state changes from false to true: when it’s false it renders a button that, if pressed, changes the state …
Testing debounced function in React component with Jest and Enzyme
I am testing a React component using Jest and Enzyme, and am having difficulty testing that a debounced function is called properly (or at all). I’ve simplified the component code below (edited to …
eslint should be listed in the project’s dependencies, not devDependencies
Either I don’t understand dependencies vs. devDependencies in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly): These are test dependencies, so why is it saying that they should be listed in dependencies? Additional note: We’re using Travis as our CI so I don’t know if it makes a difference for that at all
Components using Date objects produce different snapshots in different timezones
I’m using Enzyme with enzyme-to-json to do Jest snapshot testing of my React components. I’m testing shallow snapshots of a DateRange component that renders a display field with the current range (e.g….