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 the Selector
class. This class wraps a function that takes the current
element that has been selected and may call methods on it to narrow down the
selection further. For example:
import { Selector } from '@mojotech/prismatest-enzyme';
new Selector(e => e.find('.cool-class'))
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, { selector } from "@mojotech/prismatest-enzyme";
import TodoComponent from './todo-component';
const TodoView = testView(selector(TodoComponent), { addTodo: (e, text) => e.props().addTodo(text) });
const todo = TodoView.materialize(rendered);
todo.addTodo("Write some tests!");