npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

inferno-test-utils

v8.2.3

Published

Suite of utilities for testing Inferno applications

Downloads

4,843

Readme

inferno-test-utils

Suite of utilities for testing Inferno applications

Install

npm install inferno --save
npm install inferno-test-utils --save-dev

Contents

Usage

render(vNodeTree, DOM)

Renders vNodeTree into a detached DOM element in the document and returns a rendered VNode tree.

This function requires a DOM.

const vNodeTree = (
  <div className="outer">
    <SomeComponent className="inner"/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);

findAllInRenderedTree(renderedTree, predicate)

Calls predicate with each VNode instance in renderedTree.

Returns an array of VNodes where predicate returns true.

const vNodeTree = (
  <div className="outer">
    <SomeComponent className="inner"/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const predicate = (vNode) => vNode.type === SomeComponent;
const result = findAllInRenderedTree(renderedTree, predicate);

findAllInVNodeTree(vNodeTree, predicate)

Calls predicate with each VNode instance in vNodeTree.

Returns an array of VNodes where predicate returns true.

const vNodeTree = (
  <div className="outer">
    <SomeComponent className="inner"/>
  </div>
);
const predicate = (vNode) => vNode.type === SomeComponent;
const result = findAllInVNodeTree(vNodeTree, predicate);

scryRenderedDOMElementsWithClass(renderedTree, classNames)

Returns an array of DOM elements with classNames.

classNames can be a space-separated string or an array of strings.

const vNodeTree = (
  <div className="outer">
    <SomeComponent className="inner one"/>
    <SomeComponent className="inner two"/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = scryRenderedDOMElementsWithClass(renderedTree, 'inner');
const result2 = scryRenderedDOMElementsWithClass(renderedTree, 'inner one');
const result3 = scryRenderedDOMElementsWithClass(renderedTree, ['inner', 'two']);
const result4 = scryRenderedDOMElementsWithClass(renderedTree, 'three'); // Empty array

findRenderedDOMElementWithClass(renderedTree, classNames)

Returns a single DOM element with classNames. If more than one matches are found, throws an error.

classNames can be a space-separated string or an array of strings.

const vNodeTree = (
  <div className="outer">
    <SomeComponent className="inner one"/>
    <SomeComponent className="inner two"/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = scryRenderedDOMElementsWithClass(renderedTree, 'outer');
const result2 = scryRenderedDOMElementsWithClass(renderedTree, 'inner one');
// Will throw an error because more than 1 matches were found...
const result3 = scryRenderedDOMElementsWithClass(renderedTree, 'inner');

scryRenderedDOMElementsWithTag(renderedTree, tagName)

Returns an array of DOM elements with tagName.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <p>Paragraph One</p>
    <p>Paragraph Two</p>
    <p>Paragraph Three</p>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = scryRenderedDOMElementsWithTag(renderedTree, 'h1');
const result3 = scryRenderedDOMElementsWithTag(renderedTree, 'p');
const result4 = scryRenderedVNodesWithType(renderedTree, 'span'); // Empty array

findRenderedDOMElementWithTag(renderedTree, tagName)

Returns a single DOM element with tagName. If more than one matches are found, throws an error.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <div>
      <p>Paragraph One</p>
      <p>Paragraph Two</p>
      <p>Paragraph Three</p>
    </div>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = findRenderedDOMElementWithTag(renderedTree, 'h1');
// Will throw an error because more than 1 matches were found...
const result2 = findRenderedDOMElementWithTag(renderedTree, 'p');

scryRenderedVNodesWithType(renderedTree, type)

Returns an array of rendered VNodes with type.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <SomeComponent/>
    <SomeComponent/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = scryRenderedVNodesWithType(renderedTree, 'h1');
const result2 = scryRenderedVNodesWithType(renderedTree, SomeComponent);
const result3 = scryRenderedVNodesWithType(renderedTree, 'p'); // Empty array

findRenderedVNodeWithType(renderedTree, type)

Returns a single rendered VNode with type. If more than one matches are found, throws an error.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <p>Paragraph 1</p>
    <p>Paragraph 2</p>
    <SomeComponent/>
    <AnotherComponent/>
    <AnotherComponent/>
  </div>
);
const renderedTree = render(vNodeTree, DOM);
const result1 = findRenderedVNodeWithType(renderedTree, 'h1');
const result2 = findRenderedVNodeWithType(renderedTree, SomeComponent);
// Will throw an error because more than 1 matches were found...
const result3 = findRenderedVNodeWithType(renderedTree, 'p');
const result4 = findRenderedVNodeWithType(renderedTree, AnotherComponent);

scryVNodesWithType(vNodeTree, type)

Returns an array of VNode instances with type.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <SomeComponent/>
    <SomeComponent/>
  </div>
);
const result1 = scryVNodesWithType(vNodeTree, 'h1');
const result2 = scryVNodesWithType(vNodeTree, SomeComponent);
const result3 = scryVNodesWithType(vNodeTree, 'p'); // Empty array

findVNodeWithType(vNodeTree, type)

Returns a single VNode instance with type. If more than one matches are found, throws an error.

const vNodeTree = (
  <div>
    <h1>Heading</h1>
    <SomeComponent/>
    <SomeComponent/>
  </div>
);
const result1 = findVNodeWithType(vNodeTree, 'h1');
// Will throw an error because more than 1 matches were found...
const result2 = findVNodeWithType(vNodeTree, SomeComponent);

isVNode(instance)

Returns true when instance is a VNode.

isVNodeOfType(instance, type)

Returns true when instance is a VNode of type.

isDOMVNode(instance)

Returns true when instance is a DOM-type VNode.

isDOMVNodeOfType(instance, type)

Returns true when instance is a DOM-type VNode of type.

isFunctionalVNode(instance)

Returns true when instance is a functional-type VNode.

isFunctionalVNodeOfType(instance, type)

Returns true when instance is a functional-type VNode of type.

isClassVNode(instance)

Returns true when instance is a class-type VNode.

isClassVNodeOfType(instance, type)

Returns true when instance is a class-type VNode of type.

isDOMElement(instance)

Returns true when instance is a DOM element.

isDOMElementOfType(instance, type)

Returns true when instance is a DOM element of type.

isRenderedClassComponent(instance)

Returns true when instance is a rendered class VNode.

isRenderedClassComponentOfType(instance, type)

Returns true when instance is a rendered class VNode of type.