/Examin

Automatic React Unit Test Generator

Primary LanguageTypeScriptMIT LicenseMIT

Examin Cover


Examin

Automatic React Unit Test Generator
examin.dev | Install Examin

GitHub license Version GitHub Release PRs Welcome GitHub contributors

Features ⚡

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.

  • Install the Examin extension
  • Install npm dependencies for Jest/Enzyme
  • Navigate to the Examin panel in Chrome developer tools
  • ✨ Generate tests ✨

Preview of Examin

Installation 🔌

To get started, manually install Examin in Developer mode.

  1. Clone the repo
    git clone https://github.com/oslabs-beta/Examin.git
  2. Install NPM packages
    npm install
  3. Create a build directory
    npm run build
  4. Load the unpacked extension from src/extension to Chrome

NOTE: The React Developer Tools extension is also required for Examin to run, if you do not already have it installed on your browser.

How to Use ❓️

  1. Install Jest/Enzyme for your project

    • npm install jest enzyme enzyme-adapter-react-16 @babel/core @babel/preset-env
    • Add presets to your .babelrc file
      { "presets": ["@babel/preset-env", "@babel/preset-react"] }
  2. Run the Examin build using npm run dev

  3. Navigate to the Examin panel in Chrome DevTools

    • Must be in developer mode
    • Revise import statements as needed
  4. Add Generated tests into your application

    • Add __tests__ directory in root directory
    • Add test js file to __tests__ directory
    • Run tests using jest or jest <filename>


Editing Import Statements Demo Gif

  • Editing import statements


State Change and Component Selection Demo Gif

  • Updating tests with state changes
  • Selecting components for generated tests

Compatibility

  • Requires React v16.8.0 or higher
  • Functional components + React hooks
  • Not yet compatible with component libraries or Context API

Troubleshooting ⁉️

  • Jest docs
  • Enzyme docs
  • Error: Unable to resolve dependency tree while installing enzyme-adapter-react-16
    • Add peerDependencies to your package.json file
      "peerDependencies": { "react": "^16.8.0 || ^17.0.0", "react-dom": "^16.8.0 || ^17.0.0" }

Contributing

Examin is open source on Github through the tech accelerator umbrella OS Labs. Please read the contribution documentation to learn more on how you can participate in improvements.

Core Team ☕ 💼