Module

Enzyme

Package
purescript-react-enzyme
Repository
alvart/purescript-react-enzyme

#configure Source

configure :: Effect Unit

Configures the Enzyme adapter to provide compatibility with React.

#withGlobalDOM Source

withGlobalDOM :: Effect Unit

Registers a global DOM so that Full Wrappers can be mounted.

Re-exports from Enzyme.Full

#ReactWrapper Source

data ReactWrapper :: Type

Represents an Enzyme wrapper for components that may interact with DOM APIs or that are part of higher order components.

Instances

#remount Source

remount :: ReactWrapper -> Effect Unit

A method that re-mounts the component, if it is not currently mounted. This can be used to simulate a component going through an unmount/mount lifecycle.

#mount Source

mount :: ReactElement -> Effect ReactWrapper

Creates a ReactWrapper from a React element.

Re-exports from Enzyme.Shallow

#ShallowWrapper Source

#shallow Source

shallow :: ReactElement -> Effect ShallowWrapper

Creates a ShallowWrapper from a React element.

#reshallow Source

reshallow :: ShallowWrapper -> Effect ShallowWrapper

Shallow renders the root node and returns a shallow wrapper around it. It must be a single-node wrapper.

Re-exports from Enzyme.Wrapper

#Wrapper Source

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.

#someWhere Source

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.

#some Source

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

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

#skip Source

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.

#parent Source

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

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

#last Source

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

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

#isEmpty Source

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

Returns whether or not the wrapper is empty.

#first Source

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

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

#find Source

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.

#everyWhere Source

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.

#every Source

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

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

#enumerate Source

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

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

#childAt Source

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

Returns a new wrapper with child at the specified index.