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
1
vote
1 answer

Error 'h1.findDOMNode is not a function' when running a Karma test

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's the test script... // Article-test.jsx var React…
ckhatton
  • 1,359
  • 1
  • 14
  • 43
1
vote
1 answer

Testing React component onClick event with multiple actions in it

Can't figure it out how to test onClick function with multiple actions in it. onButtonClick = function(action){ this.props.otherAction(); action(); } ...
matejs
  • 163
  • 3
  • 17
1
vote
1 answer

React 0.14.5 Composite Components and Children's public methods

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 component and I can't see a way to get to the child's…
4m1r
  • 12,234
  • 9
  • 46
  • 58
1
vote
1 answer

ReactTestUtils.renderIntoDocument a component with children - children seem to "not render in DOM"

I render a component in my test like so: component = TestUtils.renderIntoDocument(
foo
foo
foo
Vall3y
  • 1,181
  • 8
  • 18
1
vote
1 answer

HighChart Test React error#13

I am using a High Chart component created using React. I have to write a test for it, and the infrastructure is Jasmine/Karma/React TestUtils. I have written the following code: const component: React.Component<{}, {}> =…
Programmer
  • 239
  • 3
  • 9
1
vote
1 answer

Jest + React TestUtils: Render a tag with TestUtils.renderIntoDocument

I am writing a React component that depends on a meta tag of a specific name to be present in the head area of the DOM, so I'm trying to use TestUtils.renderIntoDocument to create that meta tag for running my Jest test, which is not…
eriklharper
  • 2,882
  • 5
  • 25
  • 28
0
votes
1 answer

What's the error in the code . Line 51:8: Parsing error: Unexpected token, expected "{"

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 error: Unexpected token, expected "{") import…
0
votes
1 answer

How Can I Fix this Error with Karma & React 16.2.0?

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 = require('webpack'); const ExtractTextPlugin =…
0
votes
0 answers

Unit test case for React Component using enzyme

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 get the div tags using classname or using find…
Saranya
  • 1
  • 1
0
votes
0 answers

translate dom in react for testing purposes

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 components by React Names not by classNames or…
Nikolaos
  • 1
  • 2
0
votes
1 answer

Use react's testutils with jquery elements

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 somehow? Basically, i am trying to do something…
aakashgupta.0205
  • 647
  • 1
  • 8
  • 23
0
votes
1 answer

I get TypeError: Cannot read property 'then' of undefined when I try to test async action

I have a problem testing my async action in reactjs. Here is my code: export function fillStoryBoard(snippetsLink, channel, uniqueStoryObj, isUniqueStorySearch) { return function(dispatch){ for (var i = 0; i < snippetsLink.length; i++) { …
Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63
0
votes
1 answer

React Test : Finding Component within Component

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 use that to find an even deeper object like so…
Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225
0
votes
1 answer

Reactjs Test api call

I want to develop usign 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 litle WebApi project in .Net, this WebApi has an endpoint wich…
0
votes
1 answer

TestUtils.Simulate.change doesn't update value of input

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 is my little component : 'use strict'; var…
kMM
  • 5
  • 1
  • 5