2 |
3 |
4 |
10 |
11 |
12 |
A UI-driven test-generation package for Recoil selectors.
13 |
14 |
15 |
16 |
17 | [](https://www.npmjs.com/package/chromogen)
18 | [](https://travis-ci.org/oslabs-beta/Chromogen)
19 | [](https://coveralls.io/github/oslabs-beta/Chromogen?branch=master)
20 | [](https://github.com/oslabs-beta/Chromogen/blob/master/LICENSE)
21 |
22 | [](https://twitter.com/intent/tweet?text=CHROMOGEN%20-%20A%20UI-driven%20Jest%20test%20generator%20for%20Recoil%20apps%0A&url=https://www.npmjs.com/package/Chromogen&hashtags=React,Recoil,Jest,testing)
23 | [](http://makeapullrequest.com)
24 | [](https://www.npmjs.com/package/chromogen)
25 | [](https://github.com/oslabs-beta/Chromogen)
26 |
27 |
28 |
29 | ## Table of Contents
30 |
31 | - [Overview](#overview)
32 | - [Installation](#installation)
33 | - [Usage](#usage)
34 | - [Contributing](#contributing)
35 | - [Core Team](#core-team)
36 | - [License](#license)
37 |
38 | ## Overview
39 |
40 | You're an independent developer or part of a lean team. You want reliable unit tests for your new React-Recoil app, but you need to move fast and time is major constraint. More importantly, you want your tests to reflect how your users interact with the application, rather than testing implementation details.
41 |
42 | [Enter Chromogen](https://www.npmjs.com/package/chromogen). Chromogen is a Jest unit-test generation tool for Recoil selectors. It captures state changes during user interaction and auto-generates corresponding test suites. Simply launch your application (after following the installation instructions below), interact as a user normally would, and with one click you'll download a ready-to-run Jest test file.
43 |
44 | ### Don't have a Recoil app handy?
45 | Chromogen's [official demo app](demo-todo/README.md) provides a ready-to-run Recoil frontend with a number of different selector implementations to test against. It's available in the `demo-todo` folder of this repository and comes with Chromogen pre-installed; just run `npm install && npm start` to launch.
46 |
47 | ### Chromogen is currently in active Beta
48 | Chromogen supports three main types of test:
49 | 1. **Initial selector values** on page load
50 | 2. **Selector return values** for a given state, using snapshots captured after each state transaction.
51 | 3. **Selector _set_ logic** asserting on resulting atom values for a given `newValue` argument and starting state.
52 |
53 | These test suites will be captured for _synchronous_ selectors and selectorFamilies only. However, the presence of asyncronous selectors in your app should not cause any issues with the generated tests. Chromogen can identify such selectors at run-time and exclude them from capture.
54 |
55 | At this time, we have no plans to introduce testing for async selectors; the mocking requirements are too opaque and fragile to accurately capture at runtime. However, we are always open to suggestions to meet the needs of our userbase. Want to see this or any other feature added to the package? [Let us know!](#contributing)
56 |
57 | By default, Chromogen uses atom and selector keys to populate the import & hook statements in the test file. If your source code does _not_ use matching variable and key names, you will need to pass the imported atoms and selectors to the ChromogenObserver component as a `store` prop. The installation instructions below contain further details.
58 |
59 | _(09/15/20)_ **WARNING:** _Chromogen_ v1.3.x is only compatible with Recoil v0.0.10 currently. We are working on an update to enable compatibility with Recoil's new v0.0.11 release.
60 |
61 | ## Installation
62 |
63 | Before running Chromogen, you'll need to make two changes to your application:
64 | 1. Import the `
148 |
149 |
150 |  
151 |
152 |
153 |
154 | Before running the test file, you'll need to specify the import path for your store by replacing `