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
0
votes
1 answer

ReactTestUtils findRenderedComponentWithType throwing error not detecting by chai?

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: expects there to be one result and returns that one…
user308553
  • 1,238
  • 4
  • 18
  • 32
0
votes
1 answer

Writing React TestUtils test case for function without parameters

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 pass and function executes. How do I write test…
Stu
  • 157
  • 3
  • 18
0
votes
1 answer

React Test Utils - Spy not called when a simulated click is performed -

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 sure that's irrelevant here): const selectSpy =…
Mike Rifgin
  • 10,409
  • 21
  • 75
  • 111
0
votes
1 answer

React/Jasmine/Karma/Phantom Unit Test: findDOMNode and renderIntoDocument not working as expected

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 what my modal code looks like: import React, {…
0
votes
0 answers

ReactJS TestUtils Garbage Collection

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 method Here's a link to the…
Shawn Yoon
  • 65
  • 6
0
votes
1 answer

Sinon.stub getting called in test, but expect to be called statement fails

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 will be called in production, so that I can test the…
realisation
  • 475
  • 6
  • 19
0
votes
2 answers

Cannot call method 'toUpperCase' of undefined in simple React/Jest test

Stumped by this.. I'm trying to test that a component is rendered successfully. The test looks like: jest.dontMock("../opportunities/OpportunityList"); var OpportunityList = require("../opportunities/OpportunityList"); var opportunitiesArray =…
ttrmw
  • 161
  • 1
  • 12
0
votes
2 answers

nextState on componentWillUpdate not correct while testing with Jest (using also react-router wrapper)

I am using Jest 0.4.0. I have a component wrapped into this (from react-router docs): var stubRouterContext = (Component, props, stubs) => { function RouterStub() { } Object.assign(RouterStub, { makePath () {}, makeHref () {}, …
Ferran Negre
  • 3,712
  • 3
  • 34
  • 56
0
votes
1 answer

react testing: shallow rendering - getRenderOutput returning null

I'm just getting started with react testing, trying to use shallow rendering. I can't figure what's going on here - I believe my code follows all instructions I've seen with examples (e.g. http://racingtadpole.com/blog/test-react-with-jest/) but I'm…
Ben
  • 5,283
  • 9
  • 35
  • 44
0
votes
0 answers

React test fails to call function after click simulation

I am taking over a project from someone and it's been built in React. One of the tests is failing because a function isn't called after a click on a button has been simulated. The function is called ok when I use the app in the browser so not sure…
Dine
  • 7,223
  • 8
  • 25
  • 35
0
votes
1 answer

How can I get simulated react events to update the values of the ref in my component?

So I have a react component that looks something like this: class SignInForm extends React.Component { constructor(props) { super(props); } onFormSubmit(event) { const username =…
Joshua
  • 6,320
  • 6
  • 45
  • 62
0
votes
1 answer

ReactJS and Jest - "object-assign" - Cannot call method 'addChangeListener' of undefined

So I'm testing a component where I need it to act with my store to get the correct testable behavior. I've read that, since the "View" requires the store to function, I need to not mock the store, and also to not mock the "object-assign"…
joakimnorberg
  • 655
  • 3
  • 10
  • 16
1 2 3 4 5
6