reactjs-testutils Questions

17

https://github.com/JedWatson/react-select I would like to use React-Select react component, but I need to add tests. I've tried several options I found with google, but nothing seems to work. I h...
Journeywork asked 1/2, 2017 at 22:32

4

Solved

Consider the following input element in a React component: <input onChange={() => console.log('onChange')} ... /> While testing the React component, I'm emulating user changing the inpu...
Nolasco asked 21/8, 2016 at 13:57

8

Solved

I'm writing Jest tests for my React code and hoping to make use of/test the PropType checks. I am quite new to the Javascript universe. I'm using npm to install react-0.11.2 and have a simple: var...
Joan asked 30/9, 2014 at 15:45

3

Solved

I have following code in my component var rect = ReactDOM.findDOMNode(this).getBoundingClientRect(); I use d3js and render graph in the component. But when I run test there are any svg tags. I a...
Pin asked 29/7, 2016 at 10:29

1

I have a component with the following render function:- render: function() { <input type="file" name: this.props.name, className={this.props.className} onChange={this.props.handl...
Plow asked 20/4, 2016 at 18:40

3

Using JEST to unit test a component that has a keydown listener attached to the document. How can I test this in JEST? How do I simulate the keydown event on the document? I need the event listen...

1

Solved

Any documentation on what's the purpose of adapter in enzyme testing library. import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter()...
Sandpaper asked 25/3, 2019 at 18:36

4

Solved

I'm testing my React components under jsdom using my own tiny "virtual browser" utility. Works just fine, until I'm trying to setState. For example, when testing a children ages input control: des...
Mikkel asked 11/11, 2014 at 14:46

3

Solved

I have a very simple React mixin which uses jQuery to trigger an event MyMixin = { trackStructEvent: function () { args = Array.prototype.slice.call(arguments); $('body').trigger('myEvent', arg...
Mowery asked 28/11, 2014 at 13:1

4

I've a react component that makes AJAX call in componentDidMount method. While I try to render it using React.addons.TestUtils, the component gets rendered without making AJAX call. How would I tes...
Jackdaw asked 24/6, 2015 at 10:53

2

While writing the test case in JEST for React file I am getting this error. Following is my sample code: search_basr_test.js jest.autoMockOff(); global.React = require('react/addons'); jest.setMo...
Goren asked 23/12, 2015 at 10:38

2

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 stric...
Seriocomic asked 25/6, 2015 at 16:23

2

Solved

The component I am writing needs to change its behaviour depending on whether ctrl is pressed or not. I use a window.onkeydown event but Simulate from React Test Utils doesn't allow me to dispatch...
Featherbedding asked 5/8, 2016 at 20:34

2

Solved

I want to be able to simulate a user typing into a text box using reactjs so that I can test my validation status messages. I have a react component which validates on keyUp Below is a simple exa...
Ras asked 14/7, 2014 at 5:28

1

I am modifying an example found here: https://github.com/airbnb/enzyme/blob/master/docs/api/ReactWrapper/setProps.md class Foo extends React.Component { render() { return ( <input className...
Hawthorne asked 22/1, 2016 at 10:51

2

I'm trying to simulate a scroll event with ReactJS and JSDOM. Initially I tried the following: var footer = TestUtils.findRenderedDOMComponentWithClass(Component, 'footer'); footer.scrollTop = 500;...
Allisan asked 8/5, 2015 at 16:2

1

I've a very simple test /** @jsx React.DOM */ var store = require('../simpleStore'); var TestUtils = require('react/addons').addons.TestUtils; describe("my tests",function(){ it('simple test',f...
Midsummer asked 27/11, 2015 at 22:50

2

Solved

React Tests Fails after set State causes second render Up until now testing has been going well with JSDOM and Mocha. So far have not had to test any components that change their state. I found my...
Fletcherfletcherism asked 13/5, 2015 at 0:54

1

Solved

I'm getting the following error in my testing suite when I upgrade from React 12.2 to React 13.3: Error: Invariant Violation: unmountComponentAtNode(...): Target container is not a DOM element....
Barra asked 27/6, 2015 at 14:58

1

Solved

I have a form with 3 radio buttons like follows (fake names): <form className="myForm" onSubmit={this.done}> <input className="myRadio" checked={ŧrue} type="radio" name="myRadio" onChang...
Attic asked 20/10, 2014 at 16:41

2

I'm having trouble testing a form submit event using React, TestUtils and Jest. I have a component that renders a <form> DOM element; the same component also has a method that handles the on...
Dealing asked 24/11, 2014 at 22:25

2

My React component has a suggestionRenderer property that allows to specify how the component is rendered. For example: <Autosuggest suggestions={getSuburbs} suggestionRenderer={renderLocation...
Fibrous asked 11/3, 2015 at 5:53

1

Solved

I have a very simple React.js component that decorates a long block of markup with "Read more" / "Read less" functionality. I have a few tests with Jest working, however, I am unable to assert tha...
Liponis asked 7/2, 2015 at 22:1

1

Solved

I have the following React components, and I want to select one of the selectElements in my select-block with TestUtils. How do I do that? var selectElements = ["type_a", "type_b"]; var SelectEle...
Ratchford asked 6/11, 2014 at 12:14

1

Solved

I've set up a simple function to handle mouse wheel events on a menu component I built. The component works fine, I'm trying to write a unit test around it and that is giving me an issue. compone...
Witmer asked 3/11, 2014 at 15:34

© 2022 - 2024 — McMap. All rights reserved.