rhysforyou / Bs Enzyme
Licence: mit
Bucklescript bindings for Enzyme
Stars: ✭ 35
Programming Languages
reason
219 projects
bucklescript
41 projects
Projects that are alternatives of or similar to Bs Enzyme
React Ssr Starter
All have been introduced React environment
Stars: ✭ 20 (-42.86%)
Mutual labels: jest, enzyme
Enzyme To Json
Snapshot test your Enzyme wrappers
Stars: ✭ 954 (+2625.71%)
Mutual labels: jest, enzyme
react-boilerplate
Sets the ground up for CRA-like projects.
Stars: ✭ 23 (-34.29%)
Mutual labels: enzyme, jest
react-testing-talk
No description or website provided.
Stars: ✭ 12 (-65.71%)
Mutual labels: enzyme, jest
Youtube React
A Youtube clone built in React, Redux, Redux-saga
Stars: ✭ 421 (+1102.86%)
Mutual labels: jest, enzyme
React Redux Boilerplate
Awesome React Redux Workflow Boilerplate with Webpack 4
Stars: ✭ 307 (+777.14%)
Mutual labels: jest, enzyme
react-multi-context
Manage multiple React 16 contexts with a single component.
Stars: ✭ 19 (-45.71%)
Mutual labels: enzyme, jest
Relay Testing Utils
Easy to use relay mock and unit testing tool (works with Jest & Enzyme)
Stars: ✭ 13 (-62.86%)
Mutual labels: jest, enzyme
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+56417.14%)
Mutual labels: jest, enzyme
parcelui
Parcel + Typescript + React/Preact + Router + CSS Modules + SASS + Jest + Api-Now + Github Actions CI
Stars: ✭ 32 (-8.57%)
Mutual labels: enzyme, jest
React Generate Props
Generate default props based on your React component's PropTypes
Stars: ✭ 23 (-34.29%)
Mutual labels: jest, enzyme
testing-reactjs-examples
🧪 "What should we test in our React components" - presentation examples.
Stars: ✭ 23 (-34.29%)
Mutual labels: enzyme, jest
egghead-bookshelf
An example React application to accompany the "Add Internationalization (i18n) to a React app using React Intl" Egghead.io course
Stars: ✭ 28 (-20%)
Mutual labels: enzyme, jest
enzyme-v3-and-react-16
Example of how to setup React 16, Enzyme 3 and Jest 21
Stars: ✭ 21 (-40%)
Mutual labels: enzyme, jest
Simple React App
Simple base app using react, react-router v4, hot-reload & sass.
Stars: ✭ 263 (+651.43%)
Mutual labels: jest, enzyme
react-unit-test-practice
No description or website provided.
Stars: ✭ 16 (-54.29%)
Mutual labels: enzyme, jest
enzyme-extensions
🎩 Enzyme extensions to test shallowly rendered enzyme wrappers 🏄🏻
Stars: ✭ 30 (-14.29%)
Mutual labels: enzyme, jest
Webpack React Boilerplate
Minimal React 16 and Webpack 4 boilerplate with babel 7, using the new webpack-dev-server, react-hot-loader, CSS-Modules
Stars: ✭ 358 (+922.86%)
Mutual labels: jest, enzyme
Snapchat Clone
👻 A SnapChat clone built with React, Redux and Typescript. Styled with SASS. Tested with Cypress, Jest and Enzyme. Linted with Eslint and formatted with Prettier!
Stars: ✭ 770 (+2100%)
Mutual labels: jest, enzyme
bs-enzyme
BuckleScript bindings for Enzyme
🚧 Note: This package is still very experimental. Expect frequent, breaking changes right up until 1.0 is released. 🚧
Status
- Most of the
shallow
andmount
APIs are implemented - The
simulate
method is currently wrapped in multiplesimulateN
functions to handle mixed variadic arguments - The
render
API isn't implemented - I haven't extensively tested most of the functions, so some might be broken
Example
Using the excellent bs-jest and Airbnb's official enzyme-adapter-react-16.
open Jest;
Enzyme.configureEnzyme(Enzyme.react_16_adapter());
let setup = (~title="Test", ~handleClick=(_evt) => (), ()) =>
Enzyme.shallow(<DummyComponent title handleClick />);
let header = (wrapper) =>
wrapper
|> Enzyme.Shallow.find("#header")
|> Enzyme.Shallow.first;
let listItems = (wrapper) =>
wrapper
|> Enzyme.Shallow.find("#list")
|> Enzyme.Shallow.children;
describe("DummyComponent", () => {
open Expect;
test("renders a #header", () => {
let title = "A test title";
let wrapper = setup(~title, ());
let headerNodes = wrapper |> header;
expect(Enzyme.Shallow.length(headerNodes)) |> toBe(1)
});
test("has the expected h1 tag in the #header", () => {
let title = "A test title";
let wrapper = setup(~title, ());
let expectedNode = <h1> (ReasonReact.stringToElement(title)) </h1>;
expect(Enzyme.Shallow.contains(expectedNode, wrapper)) |> toBe(true)
});
test("initially has its `clicked` state set to false", () => {
let wrapper = setup();
let {clicked}: DummyComponent.state = Enzyme.Shallow.state(wrapper);
expect(clicked) |> toBe(false)
});
test("folds left properly", () => {
let items = setup() |> listItems;
let result = Enzyme.Shallow.foldLeft((text, node) => text ++ Enzyme.Shallow.text(node), "", items);
expect(result) |> toBe("OneTwoThree")
});
test("maps properly", () => {
let items = setup() |> listItems;
let result = Enzyme.Shallow.map(node => Enzyme.Shallow.text(node), items);
expect(result) |> toEqual([|"One", "Two", "Three"|])
});
});
See more examples in the project's tests directory.
Installation
With npm:
npm install --save-dev bs-enzyme enzyme-adapter-react-16
With Yarn:
yarn add --dev bs-enzyme enzyme-adapter-react-16
Then add bs-enzyme
to bs-dev-dependencies
in your bsconfig.json
:
{
...
"bs-dev-dependencies": ["bs-enzyme"]
}
Note: If you're using this package with bs-jest
, be sure to list
bs-enzyme
first in your dependencies.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].