Module

Enzyme.Wrapper

#Wrapper

class Wrapper w  where

The Wrapper type class represents any Enzyme wrapper of React components with an interface to manipulate or traverse them.

Members

  • at :: Int -> w -> Effect w

    Returns a wrapper around the node at a given index of the current wrapper.

  • children :: w -> Effect w

    Returns a new wrapper with all of the children of the node(s) in the current wrapper.

  • debug :: { ignoreProps :: Boolean, verbose :: Boolean } -> w -> Effect String

    Returns an HTML-like string of the wrapper for debugging purposes. Useful to print out to the console when tests are not passing when you expect them to.

  • findWhere :: (w -> Effect Boolean) -> w -> Effect w

    Finds every node in the render tree that returns true for the provided predicate function.

  • forEach :: (w -> Int -> Effect Unit) -> w -> Effect Unit

    Maps the current array of nodes to another array. Each node is passed in as a wrapper to the map function.

  • get :: Int -> w -> Effect ReactElement

    Returns the node at a given index of the current wrapper.

  • hostNodes :: w -> Effect w

    Returns a new wrapper with only host nodes. When using React-dom, host nodes are HTML elements rather than custom React components, e.g. <div> versus <MyComponent>.

  • invoke :: String -> w -> Array Foreign -> Effect Unit

    Invokes a property as a function with an Array of arguments.

  • is :: String -> w -> Effect Boolean

    Returns whether or not the single wrapped node matches the provided selector. It must be a single-node wrapper.

  • length :: w -> Effect Int

    Returns the number of nodes inside the current wrapper.

  • matches :: ReactElement -> w -> Effect Boolean

    Returns whether or not a patternNode React element matches any element in the render tree. It must be a single-node wrapper, and only the root node is checked.

  • name :: w -> Effect String

    Returns the name of the current node of this wrapper. If it's a composite component, this will be the name of the component. If it's a native DOM it will be a string of the tag name.

  • parents :: w -> Effect w

    Returns a wrapper around all of the parents/ancestors of the single node in the wrapper. Does not include the node itself.

  • property :: String -> w -> Effect Foreign

    Returns the prop value for the root node of the wrapper with the provided key. It must be a single-node wrapper.

  • reduce :: forall a. (a -> w -> Int -> Effect a) -> a -> w -> Effect a

    Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node is passed in as a wrapper, and is processed from left to right.

  • setProperty :: String -> Foreign -> w -> Aff Unit

    A method that sets the property of the root component, and re-renders. Useful for when you are wanting to test how the component behaves over time with changing props. Blocks until the operation completes.

  • slice :: Int -> Int -> w -> Effect w

    Returns a new wrapper with a subset of the nodes of the original wrapper, according to the rules of Array#slice.

  • text :: w -> Effect String

    Returns a string of the rendered text of the current render tree.

  • unmount :: w -> Effect Unit

    A method that unmounts the component. This can be used to simulate a component going through an unmount/mount lifecycle.

#childAt

childAt :: forall w. Wrapper w => Int -> w -> Effect w

Returns a new wrapper with child at the specified index.

#enumerate

enumerate :: forall w. Wrapper w => w -> Effect w

Enumerates all the nodes in the current wrapper and their children.

#every

every :: forall w. Wrapper w => String -> w -> Effect Boolean

Returns whether or not all of the nodes in the wrapper match the provided selector.

#everyWhere

everyWhere :: forall w. Wrapper w => (w -> Effect Boolean) -> w -> Effect Boolean

Returns whether or not all of the nodes in the wrapper pass the provided predicate function.

#find

find :: forall w. Wrapper w => String -> w -> Effect w

Finds every node in the render tree of the current wrapper that matches the provided selector.

#first

first :: forall w. Wrapper w => w -> Effect w

Reduce the set of matched nodes to the first in the set, just like at 0.

#isEmpty

isEmpty :: forall w. Wrapper w => w -> Effect Boolean

Returns whether or not the wrapper is empty.

#last

last :: forall w. Wrapper w => w -> Effect w

Reduce the set of matched nodes to the last in the set.

#parent

parent :: forall w. Wrapper w => w -> Effect w

Returns a wrapper with the direct parent of the node in the current wrapper.

#skip

skip :: forall w. Wrapper w => Int -> w -> Effect w

Returns a new wrapper with a subset of the nodes of the original wrapper after skipping the first n nodes.

#some

some :: forall w. Wrapper w => String -> w -> Effect Boolean

Returns whether or not any of the nodes in the wrapper match the provided selector.

#someWhere

someWhere :: forall w. Wrapper w => (w -> Effect Boolean) -> w -> Effect Boolean

Returns whether or not any of the nodes in the wrapper pass the provided predicate function.

Modules