Prismatest Enzyme Adapter
This adapter is used to interact with your test views using Enzyme.
Element Type
Elements are interacted with using Enzyme's
ReactWrapper
class.
Selector Type
Selectors are specified using functions. These functions take the current
element that has been selected and may call methods on it to narrow down the
selection further.
Selector Helper
A helper function is provided that takes the same arguments as the
find method on
ReactWrapper instances. It is essentially just a wrapper around that method.
selector: (enzymeSelector) => SelectorType
Quick Start
-
Install
yarn install --dev @mojotech/prismatest-enzyme
-
Render something
import App from "./app";
import { mount } from "enzyme";
const rendered = mount(<App />);
-
Use some test views
import testView from "@mojotech/prismatest-enzyme";
import TodoComponent from './todo-component';
const TodoView = testView(TodoComponent, { addTodo: (e, text) => e.props().addTodo(text) });
const todo = TodoView.materialize(rendered);
todo.actions.addTodo("Write some tests!");