reactjs-testutils

Test React element height with Jest

天大地大妈咪最大 提交于 2019-12-01 17:46:24
问题 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 that the DOM element height is increasing to the size of the original content. In the Jest test environment my call to getDOMNode().scrollHeight does not appear to return anything. Here is a link to the repository with the code and failing test: https://github.com/mguterl/react-jest-dom-question Below

Error: Invariant Violation: dangerouslyRenderMarkup(…): Cannot render markup in a worker thread

血红的双手。 提交于 2019-12-01 16:59:43
问题 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 first issue testing a component that changes it's state. The Error 1) Reduced Test Case - @current Tests that Fail when Component changes state and renders "before each" hook: Error: Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure `window` and

Error: Invariant Violation: findAllInRenderedTree(…): instance must be a composite component

爷,独闯天下 提交于 2019-12-01 16:27:26
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('../stores/browser_store.jsx'); beforeEach(function() { var search_bar = require('../components/search_bar.jsx'); }); var TestUtils = React.addons.TestUtils; describe("Test", function() { it("should render Test", function() { var test = TestUtils.renderIntoDocument(<search_bar/>); expect(test).toBeDefined(); }); it("renders a list in a box with proper CSS classes", function() { var test = TestUtils

How to test React PropTypes through Jest?

ε祈祈猫儿з 提交于 2019-11-30 04:31:41
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 React = require('react/addons'); In my tests. My test looks quite similar to the jest/react tutorial example with code like: var eventCell = TestUtils.renderIntoDocument( <EventCell slot={slot} weekId={weekId} day={day} eventTypes={eventTypes} /> ); var time = TestUtils.findRenderedDOMComponentWithClass(eventCell, 'time'); expect(time.getDOMNode().textContent).toEqual('19:00 '); However it seems that

How to test React PropTypes through Jest?

血红的双手。 提交于 2019-11-29 01:40:22
问题 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 React = require('react/addons'); In my tests. My test looks quite similar to the jest/react tutorial example with code like: var eventCell = TestUtils.renderIntoDocument( <EventCell slot={slot} weekId={weekId} day={day} eventTypes={eventTypes} /> ); var time = TestUtils