Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
440 views

I am learning reactjs and I am getting parsing error in last line export App3; Please go through the below code guys and let me know what's the error(What's the error in the code . Line 51:8: Parsing ...
Abhishek's user avatar
1 vote
2 answers
50 views

How can I declare currDate globally to use it in useState. The following code works just fine but wish to make it more efficient. Is there any better way to shorten the code? import React, { useState }...
Abhishek's user avatar
1 vote
1 answer
210 views

Suppose we have a functional component as below. const Test: React.FC = () => { const isItemSelected = () => { console.log('Hi); }; return ( <div> </div> ); }; And I want ...
Gowthamr.cs's user avatar
2 votes
1 answer
2k views

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) { ...
Mr.'s user avatar
  • 10.2k
3 votes
2 answers
5k views

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 } ...
swapnilpatil24's user avatar
15 votes
1 answer
6k views

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() });...
Sai Ram's user avatar
  • 4,442
1 vote
1 answer
2k views

We have used React JS for front end and we need to write end to end tests. After researching online, we came across 2 options : 1. Selenium WebDriver 2. React Test Utils (https://reactjs.org/docs/...
j10's user avatar
  • 2,291
1 vote
1 answer
13k views

I cannot write correct test case for button property disable. I use TestUtils from react-addons-test-utils. I have very simple component: const propTypes = { disabled: PropTypes.func.isRequired ...
user's user avatar
  • 4,860
0 votes
1 answer
359 views

I have this Karma configuration (with React 16.2.0): const isArray = require('lodash/lang/isArray'); const merge = require('lodash/object/merge'); const path = require('path'); const webpack = ...
Héctor's user avatar
  • 36
1 vote
1 answer
1k views

I have written simple react-apollo component which uses graphql query to retrieve data from schema. On execution component works fine but, when I am writing test case for this component using jest ...
Pramod Jadhav's user avatar
0 votes
0 answers
164 views

I am working on reactjs 5.X version. I am writing UT with enzyme. Below is my reusable component with prop arguments. Not able to find the div tags inside of the const component.Can you help me how to ...
Saranya's user avatar
2 votes
0 answers
296 views

Having an issue with testing components. I have a Voting component that renders a Vote component, and the Vote component renders two <button> tags. Using mocha+chai and react-dom/test-utils ...
speakingcode's user avatar
  • 1,506
0 votes
0 answers
65 views

Hi guys I have a question for anybody that can help. Is there any helper function to translate a document.body to React structure and access it like getElementBy.. ? So I can access the individual ...
Nikolaos's user avatar
4 votes
1 answer
677 views

I have this code below written in typescript which use ReactTestUtils from "react-dom/test-utils". let nameInput = TestUtilsExtended.findRenderedDOMComponentWithTag(root, "input"); TestUtilsExtended....
samAlvin's user avatar
  • 1,678
0 votes
1 answer
51 views

I am trying to test a react page. Using .trigger("input", {which: 65}) doesn't seem to invoke the SyntheticEvent. So I was wondering if was possible to combine jQuery and .simulate of the testUtils ...
aakashgupta.0205's user avatar
3 votes
2 answers
708 views

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(){ ...
Hamed Minaee's user avatar
  • 2,590
0 votes
1 answer
1k views

I have a problem testing my async action in reactjs. Here is my code: export function fillStoryBoard(snippetsLink, channel, uniqueStoryObj, isUniqueStorySearch) { return function(dispatch){ ...
Hamed Minaee's user avatar
  • 2,590
1 vote
1 answer
2k views

Currently in my project I'm using Karma and Mocha, with React Test-Utils to test my react components. I currently have around 1200 tests, most of which are for my library of react components. When ...
CD-jS's user avatar
  • 1,119
0 votes
1 answer
795 views

I can find a component at the first 'finder' in the code below var myComponent = ReactTestUtils.findRenderedDOMComponentWithClass(myDiv, 'myComponent') If I then use the returned Component object and ...
Oliver Watkins's user avatar
3 votes
1 answer
2k views

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 } ...
Jshoe523's user avatar
  • 4,271
1 vote
1 answer
1k views

I am writing a test case for a particular component I created. The component is here import React, { PropTypes } from 'react'; import moment from 'moment'; const RouteHeader = ({ activeTab, ...
Tarang Hirani's user avatar
0 votes
1 answer
1k views

I want to develop using Reactjs, I made an App where I call an API (https://jsonplaceholder.typicode.com/users), also I made a test for this call and I couldn't call this API. I made a little WebApi ...
ernesto petit's user avatar
50 votes
17 answers
90k views

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 have ...
Llewellyn's user avatar
  • 731
1 vote
3 answers
132 views

I keep getting this error when testing my TodoList component: debug.html:38 Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for ...
Funk Soul Ninja's user avatar
1 vote
1 answer
1k views

I am trying to do unit tests at react components with mocha, chai and sinon. My first test worked, it is simple checking if component exists and if props are used correctly. Now I having trouble ...
Alessander Franca's user avatar
1 vote
0 answers
838 views

Tests run, but they are rendering into the same document. On componentDidMount Style component appends CSS text to a style element in head with the class .reactive-style (know this is unorthodox and ...
Joshua Robinson's user avatar
31 votes
4 answers
38k views

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 input ...
Misha Moroshko's user avatar
2 votes
1 answer
2k views

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; ...
be-codified's user avatar
  • 6,174
6 votes
2 answers
4k views

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 ...
Javier Conde's user avatar
  • 2,583
4 votes
0 answers
331 views

I've taken a ReactJS component (rendering the latest gist URL for a given user) from the React docs, and was wondering what is the best way to unit test such a component : The goals are Test in ...
ddewaele's user avatar
  • 22.6k
18 votes
3 answers
25k views

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 assume ...
Gleb's user avatar
  • 1,332
0 votes
1 answer
3k views

I make a very easy component to test the TestUtils.Simulate reactJS method. But I don't know why this method doesn't update the value of my component. I guess I wrote my code on the wrong way. This ...
kMM's user avatar
  • 5
2 votes
1 answer
5k views

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 ...
user308553's user avatar
  • 1,270
0 votes
1 answer
503 views

Im using findRenderedComponentWithType to make sure there is a error, and Im using chai's assert.throws, but it is not working. first of all: TestUtils.findRenderedComponentWithType documentation: ...
user308553's user avatar
  • 1,270
0 votes
1 answer
117 views

So I have a function to remove all tabbing from a particular page. There is a variable declared in this function that does the work. I need to pass dummy value to this variable so that the value will ...
Stu's user avatar
  • 157
23 votes
1 answer
4k views

I have a component with the following render function:- render: function() { <input type="file" name: this.props.name, className={this.props.className} onChange={this....
fbielejec's user avatar
  • 3,750
1 vote
1 answer
116 views

I am trying to write a simple test. I have Karma as the test runner and Mocha as the framework. Each time I run the test, it fails with the error... TypeError: h1.findDOMNode is not a function Here'...
ckhatton's user avatar
  • 1,643
2 votes
1 answer
293 views

I have an HTML5 file type input in a React form similar to the following <input type='file' ref='fileInput' onChange={this.onChange} multiple/> and once a file is uploaded this.onChange ...
lobobabysaurus's user avatar
0 votes
1 answer
417 views

I'm trying to simulate a click on a dom element in a react component and assert that a spy is called based on this. Here's the relevant part of the test (using karma, mocha, chai, sinon but I'm fairly ...
Mike Rifgin's user avatar
  • 10.9k
4 votes
2 answers
5k views

I had this problem in the past while using older versions of react-router which I solved using: stubRouterContext + a hacky way to access the component instance (using refs: https://github.com/reactjs/...
Ferran Negre's user avatar
  • 3,821
1 vote
1 answer
4k views

Can't figure it out how to test onClick function with multiple actions in it. onButtonClick = function(action){ this.props.otherAction(); action(); } ... <Button bsStyle="success" bsSize="...
matejs's user avatar
  • 163
10 votes
1 answer
20k views

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 ( &...
Daniel Billingham's user avatar
0 votes
1 answer
577 views

I'm trying to write a simple unit test and can't seem to figure it out. I want to test a bootstrap modal to ensure it displays the correct contents when I pass certain object properties to it. Here's ...
xveganxxxedgex's user avatar
1 vote
1 answer
407 views

I'm trying to test the public method on a React Class. This is easy enough as you can see in the first spec, but if I need to provide context, the component needs to be wrapped in a composite ...
4m1r's user avatar
  • 12.6k
0 votes
0 answers
436 views

For ReactJS's test utility class : TestUtils, how do they handle garbage collection? There are no methods that de-allocate or destroy a React Module that was created beforehand in renderIntoDocument ...
Shawn Yoon's user avatar
11 votes
2 answers
3k views

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.setMock('...
Arif Usman's user avatar
  • 1,798
4 votes
5 answers
19k views

I am currently writing unit tests for my React + MaterialUi application. In my application I have a Dialog. I want to make sure depending on what button pressed on the dialog: <FlatButton label=...
jonas.hartwig's user avatar
1 vote
1 answer
677 views

I render a component in my test like so: component = TestUtils.renderIntoDocument( <SlidingContainer {...props}> <div style={divStyle}>foo</div> <div style={divStyle}&...
Vall3y's user avatar
  • 1,181
5 votes
1 answer
3k views

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',...
Sahas's user avatar
  • 3,216
0 votes
1 answer
1k views

I have a stateless react component that has an onClick method that I'm trying to test is getting called. The way I'm doing it is to set a prop with a default value pointing towards the method that ...
realisation's user avatar