Get started with inferno-test-utils CDN

MIT licensed

Inferno-test-utils is a library for testing React-like components using Inferno rendering engine.

Tags:
  • babel
  • react
  • inferno
  • framework
  • interfaces
  • tests
  • utils

Stable version

Copied!

How to start using inferno-test-utils CDN


import React from 'react';
import { render, fireEvent } from 'inferno-test-utils';
import MyComponent from './MyComponent';

test('MyComponent test', () => {
  const { getByTestId } = render(<MyComponent />);

  const inputElement = getByTestId('input');
  const buttonElement = getByTestId('button');

  fireEvent.change(inputElement, { target: { value: 'test' } });
  fireEvent.click(buttonElement);

  // Add assertions here to check the component's behavior after the button click
});

// MyComponent.js
class MyComponent extends React.Component {
  state = {
    inputValue: '',
  };

  handleInputChange = (event) => {
    this.setState({ inputValue: event.target.value });
  };

  handleButtonClick = () => {
    // Perform some action based on the input value
  };

  render() {
    return (
      <div>
        <input data-testid="input" type="text" onChange={this.handleInputChange} />
        <button data-testid="button" onClick={this.handleButtonClick}>
          Click me
        </button>
      </div>
    );
  }
}

export default MyComponent;
Copied!
Copied!

All versions

0.5.20 0.5.21 0.5.22 0.6.0 0.6.1 0.6.2 0.6.3 0.6.4 0.7.0 0.7.1 0.7.10 0.7.11 0.7.12 0.7.13 0.7.14 0.7.15 0.7.16 0.7.17 0.7.2 0.7.20 0.7.21 0.7.22 0.7.23 0.7.24 0.7.25 0.7.26 0.7.27 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0-alpha1 0.8.0-alpha2 0.8.0-alpha3 0.8.0-alpha4 0.8.0-alpha6 1.0.0-alpha1 1.0.0-alpha10 1.0.0-alpha11 1.0.0-alpha2 1.0.0-alpha3 1.0.0-alpha4 1.0.0-alpha5 1.0.0-alpha6 1.0.0-alpha7 1.0.0-alpha8 1.0.0-alpha9 1.0.0-beta1 1.0.0-beta10 1.0.0-beta11 1.0.0-beta12 1.0.0-beta13 1.0.0-beta14 1.0.0-beta15 1.0.0-beta16 1.0.0-beta17 1.0.0-beta18 1.0.0-beta19 1.0.0-beta2 1.0.0-beta20 1.0.0-beta21 1.0.0-beta22 1.0.0-beta23 1.0.0-beta24 1.0.0-beta25 1.0.0-beta26 1.0.0-beta27 1.0.0-beta28 1.0.0-beta29 1.0.0-beta3 1.0.0-beta30 1.0.0-beta31 1.0.0-beta32 1.0.0-beta33 1.0.0-beta34 1.0.0-beta35 1.0.0-beta36 1.0.0-beta37 1.0.0-beta38 1.0.0-beta39 1.0.0-beta4 1.0.0-beta40 1.0.0-beta41 1.0.0-beta42 1.0.0-beta43 1.0.0-beta44 1.0.0-beta45 1.0.0-beta5 1.0.0-beta6 1.0.0-beta7 1.0.0-beta8 1.0.0-beta9 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.0-rc.0 1.3.0-rc.1 1.3.0-rc.10 1.3.0-rc.2 1.3.0-rc.3 1.3.0-rc.4 1.3.0-rc.5 1.3.0-rc.6 1.3.0-rc.7 1.3.0-rc.8 1.3.0-rc.9 1.3.1 1.4.0 1.4.1 1.4.2 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.6.0 1.6.1 1.6.2 2.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.10.0 3.10.1 3.2.0 3.2.1 3.2.2 3.3.0 3.3.1 3.4.0 3.4.2 3.4.3 3.4.4 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.6.0 3.6.1 3.6.3 3.6.4 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.9.0 4.0.0 4.0.0-0 4.0.0-1 4.0.0-10 4.0.0-11 4.0.0-12 4.0.0-13 4.0.0-14 4.0.0-15 4.0.0-16 4.0.0-17 4.0.0-18 4.0.0-19 4.0.0-2 4.0.0-20 4.0.0-21 4.0.0-3 4.0.0-4 4.0.0-5 4.0.0-6 4.0.0-7 4.0.0-8 4.0.0-9 4.0.0-alpha1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