@mojotech/prismatest-enzyme
TypeScript icon, indicating that this package has built-in type declarations

0.2.7 • Public • Published

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

  1. Install

    yarn install --dev @mojotech/prismatest-enzyme
  2. Render something

    import App from "./app";
    import { mount } from "enzyme";
    
    const rendered = mount(<App />);
  3. 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!");

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.7
    3
    • latest

Version History

Package Sidebar

Install

npm i @mojotech/prismatest-enzyme

Weekly Downloads

12

Version

0.2.7

License

MIT

Unpacked Size

11.4 kB

Total Files

4

Last publish

Collaborators

  • cpjolicoeur
  • danielwilsonthomas-mj
  • mulias