All Projects → ReactVT → React Vt

ReactVT / React Vt

Licence: other
Data-driven visual testing library for React developers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Vt

Should Enzyme
Useful functions for testing React Components with Enzyme.
Stars: ✭ 41 (-87.94%)
Mutual labels:  tdd, enzyme
React Tdd Guide
A series of examples on how to TDD React
Stars: ✭ 585 (+72.06%)
Mutual labels:  tdd, enzyme
my-react-todolist
A guide to TDD a React/Redux TodoList App
Stars: ✭ 22 (-93.53%)
Mutual labels:  enzyme, tdd
Enzyme Matchers
Jasmine/Jest assertions for enzyme
Stars: ✭ 881 (+159.12%)
Mutual labels:  tdd, enzyme
Examin
Examin is a developer tool that generates React unit tests for your application. Ensure your application renders as expected before adding new features. Examin writes the baseline unit tests and allows developers to customize their tests for their application.
Stars: ✭ 75 (-77.94%)
Mutual labels:  enzyme, tdd
Simple React App
Simple base app using react, react-router v4, hot-reload & sass.
Stars: ✭ 263 (-22.65%)
Mutual labels:  enzyme
Xunitfor1c
Unit testing tools for 1C:Enterprise 8 platform (http://v8.1c.ru)
Stars: ✭ 305 (-10.29%)
Mutual labels:  tdd
mocha-snapshots
Snapshot/regression testing for using with Mocha, specially for React+Enzyme users.
Stars: ✭ 53 (-84.41%)
Mutual labels:  enzyme
gomatch
Library created for testing JSON against patterns.
Stars: ✭ 41 (-87.94%)
Mutual labels:  tdd
Rick And Morty Info
Made with Clean architecture + TDD + GraphQL + flutter_bloc + CodeCov + GitHooks + GitHub Actions (CI/CD) and finally with 💙
Stars: ✭ 333 (-2.06%)
Mutual labels:  tdd
Lest
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
Stars: ✭ 316 (-7.06%)
Mutual labels:  tdd
Reminders
An iOS application written in Swift to demonstrate how to implement a Clean Architecture in iOS
Stars: ✭ 293 (-13.82%)
Mutual labels:  tdd
Stormpot
A fast object pool for the JVM
Stars: ✭ 267 (-21.47%)
Mutual labels:  tdd
React Redux Boilerplate
Awesome React Redux Workflow Boilerplate with Webpack 4
Stars: ✭ 307 (-9.71%)
Mutual labels:  enzyme
Kotlin Modular Tdd Coroutines Mvvm
A sample Kotlin app which was built with modular structure, Kotlin DSL, Kotlin Coroutines, TDD and MVVM patterns.
Stars: ✭ 256 (-24.71%)
Mutual labels:  tdd
Playgroundtdd
Small library to easily run your tests directly within a Playground
Stars: ✭ 319 (-6.18%)
Mutual labels:  tdd
react-boilerplate
Sets the ground up for CRA-like projects.
Stars: ✭ 23 (-93.24%)
Mutual labels:  enzyme
Clean Mvvm Archcomponents
👽 Android app consuming Star Wars API.Built with clean architecture ,MVVM pattern, Koin , Coroutines + Flows ,Architecture Components, Data Binding , Firebase , Unit/UI Tests ,Motion Layout
Stars: ✭ 285 (-16.18%)
Mutual labels:  tdd
Tdd Ebook
Test-Driven Development - Extensive Tutorial. Open Source ebook
Stars: ✭ 314 (-7.65%)
Mutual labels:  tdd
Mockqueryable
Moking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
Stars: ✭ 281 (-17.35%)
Mutual labels:  tdd

React VT

React VT presents a live view of the React component structure of your app, along with current state and props.

Users can define assertions and test them in real time while interacting with their application. Once the user is satisfied with their defined tests, they can export their assertions into an Enzyme file.

Image of demo

Set Up

Please make sure that your application is running React and React-DOM version 15.x

  1. Run npm install for React VT in your root project folder
npm install --save-dev react-vt
  1. Import React VT in your top-level component and use your imported React class and 'this' as arguments to React VT in the componentWillMount lifecycle.
import React, { Component } from 'react';
// Add import statement
import reactVT from 'react-vt';

class App extends Component {
  // Add your own componentWillMount if there is not an existing one
  componentWillMount() {
    // Add this line in componentWillMount
    reactVT(React, this);
  }
}
  1. Install the React VT Chrome Developer Tool from the Chrome Store.

  2. Run your React application in Chrome

  3. Open Chrome Developer Tools -> React VT panel

Usage

Terminology

  • Assertion Block: An assertion block is a collection of actions and tests to define your assertion. This is analogous to it statements in Mocha tests. At least one test or action is required for an assertion block to be valid.
  • Action: Actions can be added to your assertion block to build your test case. Click, double click, right click, and enter are available as actions. Enzyme exports are currently unsupported for Enter actions.
  • Test: Equal, not equal, greater than and less than comparisons can be done on props, state, and text nodes.

Creating an assertion block

  1. Click on new assertion block and enter a name - e.g. 'should render a button'. This will be the statement that will appear on an exported Enzyme test:
it('should render a button', () => {...});
  1. To create an action, click on a tree node in order to specify the component that the action will be done on and select an action type.
  2. To create a test:
    1. Select target
      • Node: Selected tree node, which refers to a component
      • Component: Specify a component to test the number of components (length) or a particular component (index)
      • ID: Select an element by ID to test text content
      • Class: Select elements by class to test the number of elements that match the className (length) or a particular element of the class (index)
      • Tag: Select a tag type to select elements that are not categorized as class or ID
    2. Select source: state, props, or both will show up as selections if they exist. Only text is available as a source with ID, class, and tag targets.
      • Property: Select a property within the state or props
      • Modifier: If the property value is an array, a modifier is available to select either the length or an index to select an element from the array
    3. Set Expectation
      • Select the data type for the expectation to compare to - string, number, boolean, undefined, and null are available
      • Select a comparator - equal, not equal, greater than, and less than are available
      • Set the expected value

Exporting Tests into an Enzyme File

Once you're satisfied with your tests, you can export them as an Enzyme file and use it as a basis to start writing your own Enzyme tests. Enzyme exports are generated based on the Mocha test framework and Chai assertion library.

Note that Enter actions are currently unsupported for this feature.

  1. Clicking the 'Export to Enzyme' button will initiate a download. Check your default downloads folder and look for the generated 'enzymeTest.js' file.
  2. Make sure that you've installed Mocha, Chai, and Enzyme in your project.
  3. Transfer your enzymeTest.js file into your test folder.
  4. The generated test will resemble something similar to below. Replace the import path with the location of your top-level component.
const expect = require('chai').expect;
import React from 'react';
import { mount } from 'enzyme';
import 'jsdom-global/register';

// MAKE SURE TO UPDATE THE PATH BELOW TO THE LOCATION OF YOUR TOP-LEVEL COMPONENT
import App from 'fill this in with proper path';

describe('React VT Tests', () => {
  let wrapper;
  beforeEach(() => {
    wrapper = mount(<App />);
  });
 
  it('should equal X', () => {
    wrapper.find('#board').childAt(0).childAt(0).simulate('click');
  expect(wrapper.find('Square').at(0).props().letter).to.equal('X');
  });
 
});
  1. Run your test suite.

Other Notes

  1. React-router and NextJS are currently unsupported. We are looking into supporting react-router in a future release.
  2. Multiple actions and tests can be defined in one assertion block. Once you're ready to test, save the assertion block. Saved assertion blocks are stored in LocalStorage and are restored the next time React VT is opened.
  3. To run through your actions and tests, execute them in your React application while React VT Developer Tool is open to view live test results (e.g. clicking the button that you've specified as an action in your assertion block).
  4. Tests will not run until the actions that precede them are completed.

Image of Block

E.g. Test to check the value of Square will not run until the click action on Square has occurred.

Contributing

Please submit issues/pull requests if you have feedback or would like to contribute. If you're interested in joining the React VT team as a contributor, feel free to message one of us directly.

Authors

Brian Schmalz (https://github.com/bschmalz)

Ian Rustandi (https://github.com/icrustandi)

Ian Ramos (https://github.com/ibramos)

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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].