9.0.3 • Published 4 months ago

inferno-test-utils v9.0.3

Weekly downloads
199
License
MIT
Repository
github
Last release
4 months ago

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.

9.0.3

4 months ago

9.0.2

5 months ago

9.0.1

5 months ago

9.0.0

5 months ago

9.0.0-alpha.4

5 months ago

9.0.0-alpha.3

5 months ago

9.0.0-alpha.2

7 months ago

9.0.0-alpha.1

7 months ago

5.6.3

11 months ago

8.2.3

2 years ago

8.2.2

2 years ago

8.2.1

2 years ago

8.2.0

2 years ago

8.1.1

2 years ago

8.1.0

2 years ago

8.0.6

2 years ago

8.0.5

3 years ago

8.0.4

3 years ago

8.0.0-alpha.6

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

8.0.0-alpha.5

3 years ago

8.0.0-alpha.4

3 years ago

8.0.0-alpha.3

4 years ago

8.0.0-alpha.2

4 years ago

7.4.11

4 years ago

8.0.0-alpha.1

4 years ago

8.0.0-alpha.0

4 years ago

7.4.10

4 years ago

7.4.9

4 years ago

7.4.8

4 years ago

7.4.7

4 years ago

5.6.2

4 years ago

7.4.6

5 years ago

7.4.4

5 years ago

7.4.5

5 years ago

7.4.3

5 years ago

7.4.2

5 years ago

7.4.1

5 years ago

7.4.0

5 years ago

7.3.3

6 years ago

7.3.2

6 years ago

7.3.1

6 years ago

7.3.0

6 years ago

7.2.1

6 years ago

7.2.0

6 years ago

7.1.13

6 years ago

7.1.12

6 years ago

7.1.11

6 years ago

7.1.10

6 years ago

7.1.9

6 years ago

7.1.8

6 years ago

7.1.7

6 years ago

7.1.6

6 years ago

7.1.5

6 years ago

7.1.4

6 years ago

7.1.3

6 years ago

7.1.2

6 years ago

7.1.1

6 years ago

7.1.0

6 years ago

7.0.5

6 years ago

7.0.4

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.3.1

7 years ago

6.3.0

7 years ago

6.2.1

7 years ago

6.2.0

7 years ago

6.1.5

7 years ago

6.1.4

7 years ago

6.1.3

7 years ago

6.1.2

7 years ago

6.1.1

7 years ago

6.1.0

7 years ago

6.0.3

7 years ago

6.0.2

7 years ago

6.0.1

7 years ago

6.0.0

7 years ago

6.0.0-rc.5

7 years ago

6.0.0-rc.3

7 years ago

6.0.0-rc.1

7 years ago

6.0.0-rc.0

7 years ago

6.0.0-alpha.3

7 years ago

6.0.0-alpha.2

7 years ago

6.0.0-alpha.1

7 years ago

5.6.1

7 years ago

5.6.0

7 years ago

6.0.0-alpha.0

7 years ago

5.5.0

7 years ago

5.4.2

7 years ago

5.4.1

7 years ago

5.4.0

7 years ago

5.3.0

7 years ago

5.2.0

7 years ago

5.1.1

7 years ago

5.1.0

7 years ago

5.0.6

7 years ago

5.0.5

7 years ago

5.0.4

7 years ago

5.0.3

7 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

5.0.0-2

7 years ago

5.0.0-1

7 years ago

5.0.0-0

7 years ago

4.0.8

7 years ago

4.0.7

7 years ago

4.0.6

7 years ago

4.0.5

7 years ago

4.0.4

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

4.0.0-21

7 years ago

4.0.0-20

7 years ago

4.0.0-19

7 years ago

4.0.0-18

7 years ago

4.0.0-17

7 years ago

4.0.0-16

7 years ago

4.0.0-15

7 years ago

4.0.0-14

7 years ago

4.0.0-13

7 years ago

4.0.0-12

7 years ago

4.0.0-11

7 years ago

4.0.0-10

7 years ago

4.0.0-9

7 years ago

4.0.0-8

7 years ago

4.0.0-7

7 years ago

4.0.0-6

7 years ago

4.0.0-5

7 years ago

4.0.0-4

7 years ago

4.0.0-3

8 years ago

4.0.0-2

8 years ago

4.0.0-1

8 years ago

4.0.0-0

8 years ago

3.10.1

8 years ago

3.10.0

8 years ago

3.9.0

8 years ago

3.8.2

8 years ago

3.8.1

8 years ago

3.8.0

8 years ago

3.7.1

8 years ago

3.7.0

8 years ago

3.6.4

8 years ago

3.6.3

8 years ago

4.0.0-alpha1

8 years ago

3.6.1

8 years ago

3.6.0

8 years ago

3.5.4

8 years ago

3.5.3

8 years ago

3.5.2

8 years ago

3.5.1

8 years ago

3.5.0

8 years ago

3.4.4

8 years ago

3.4.3

8 years ago

3.4.2

8 years ago

3.4.0

8 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.2

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.6

8 years ago

3.0.5

8 years ago

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.6

8 years ago

1.5.5

8 years ago

1.5.4

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.3.0-rc.10

8 years ago

1.3.0-rc.9

8 years ago

1.3.0-rc.8

8 years ago

1.3.0-rc.7

8 years ago

1.3.0-rc.6

8 years ago

1.3.0-rc.5

8 years ago

1.3.0-rc.4

8 years ago

1.3.0-rc.3

8 years ago

1.3.0-rc.2

8 years ago

1.3.0-rc.1

8 years ago

1.3.0-rc.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0-beta45

8 years ago

1.0.0-beta44

8 years ago

1.0.0-beta43

8 years ago

1.0.0-beta42

9 years ago

1.0.0-beta41

9 years ago

1.0.0-beta40

9 years ago

1.0.0-beta37

9 years ago

1.0.0-beta36

9 years ago

1.0.0-beta9

9 years ago

1.0.0-beta6

9 years ago

0.7.27

9 years ago

0.7.26

9 years ago

0.7.25

9 years ago

0.7.24

9 years ago

0.7.23

9 years ago

0.7.22

9 years ago

0.7.21

9 years ago

0.7.20

9 years ago

0.7.17

9 years ago

0.7.16

9 years ago

0.7.15

9 years ago

0.7.14

9 years ago

0.7.13

9 years ago

0.7.12

9 years ago

0.7.11

9 years ago

0.7.10

9 years ago

0.7.9

9 years ago

0.7.7

9 years ago

0.7.0

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.0

9 years ago

0.5.22

9 years ago

0.5.21

9 years ago

0.5.20

9 years ago