Questions tagged [reactjs-testutils]

Unit testing helpers for reactjs

ReactJs TestUtils are provided in the 'with-addons' react package and allow you to perform actions against a simulated DOM for the purposes of unit testing. See the documentation here.

87 questions
4
votes
1 answer

Why Jest is throwing "Unexpected token ILLEGAL" when testing React component?

I followed the Jest - React tutorial to test a React component. Unfortunately, Jest throws: SyntaxError: /Users/mishamoroshko/react-playground/src/search-panel/questions/__tests__/questions-test.js:…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
4
votes
1 answer

How do I use Jest to test a React view wired to store?

I have a React view that communicates with a store. I've successfully tested views and stores separately, but not in combination. I followed the structure documented here but received a TypeError. It looks like Jest is trying to register the store…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
3
votes
2 answers

how to test combineReducers with jest

I am trying to test combineReducers but getting following error. TypeError: _testReducer.testReducer.test11 is not a function Following is the reducer // testReducer.js import { combineReducers } from "redux-immutable"; const test11 = (state,…
3
votes
1 answer

ReactTestUtils Simulate.Change parameter type SyntheticEventData error

I have this code below written in typescript which use ReactTestUtils from "react-dom/test-utils". let nameInput = TestUtilsExtended.findRenderedDOMComponentWithTag(root, "input"); TestUtilsExtended.Simulate.change(nameInput, { target: { …
3
votes
2 answers

mock a function which is used in another function

I am writing test for my async action in react redux, for sake of addressing just the issue I simplified the code here. Here is my action function: export function updateUserAuthenticationStatus(){ return function(dispatch){ return…
Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63
3
votes
1 answer

React.js and Jasmine Spies

Using basic test-utils and jasmine for unit testing. How do you spy on a function inside a react component? test.js: class Test extends React.Component { handleClick() { // Do something } render() { return (
Jshoe523
  • 3,851
  • 2
  • 18
  • 21
3
votes
1 answer

Using React.addons.TestUtils to reactjs test components

I am reading the reactjs documentation but I am having a having a hard time fully understanding it. I wish there were more step by step examples. I want to be able to test my components and their child components but I am not sure how to create…
Liondancer
  • 15,721
  • 51
  • 149
  • 255
3
votes
2 answers

React TestUtils, how can I simulate document mouseMove?

I want to use TestUtils.Simulate.mouseMove on the document. I have a component Dragger that adds a mouseMove event listener to the document. Here is an incomplete version: // Dragger.js 'use strict'; var React = require('react'); export default…
well
  • 647
  • 1
  • 8
  • 20
3
votes
1 answer

React Mocha rendering, DOMException Wrong Document

Using React 13.2 and looking to test lifecyles with a setup like the one shown on this gist. If I don't stop subsequent renders (via the shouldComponentUpdate method) then anything causes a render (after the initial) explodes with a DOMException…
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
3
votes
1 answer

Trouble using TestUtils.Simulate to create a change event on an input element

I'm trying to write tests in jest for the examples shown in "Thinking in React" (http://facebook.github.io/react/docs/thinking-in-react.html) And I am having a hard time using TestUtils.Simulate to provide a change-event to the search input…
pbanka
  • 716
  • 1
  • 8
  • 20
2
votes
1 answer

testing nested component callback in react

given a Foo (root) component that renders Baz nested component, where Baz has a property named onOperationDone which accepts a callback. class Foo extends React.Component { constructor(props) { super(props); this.onOperationDone = () =>…
Mr.
  • 9,429
  • 13
  • 58
  • 82
2
votes
0 answers

React test-utils scryRenderedDOMComponentsWith* not traversing nested components

Having an issue with testing components. I have a Voting component that renders a Vote component, and the Vote component renders two
speakingcode
  • 1,518
  • 13
  • 12
2
votes
1 answer

React testing: Change value of input field

I can not set the value of input field. What am I doing wrong? If any more information is needed, please tell me so. Thank you. describe('SignUpComp', () => { let signUpComp, node; beforeEach(() => { signUpComp =…
be-codified
  • 5,704
  • 18
  • 41
  • 65
2
votes
1 answer

react testUtils simulate click on a radio button not triggering onchange

For testing Im using JSDom, mocha, chai and ReactTestUtils. One of my component got three radio button, that when a change is detected (onChange) will run a function. Everything works in manual testing, but I cant seem to trigger the function when…
user308553
  • 1,238
  • 4
  • 18
  • 32
2
votes
1 answer

How to set HTML5 file type input with ReactTestUtils

I have an HTML5 file type input in a React form similar to the following and once a file is uploaded this.onChange accesses the selected files, validates them and transitions…
lobobabysaurus
  • 247
  • 2
  • 10