Automatic React Unit Test Generator Examin
examin.dev | Install Examin
⚡
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✨
🔌
Installation To get started, manually install Examin in Developer mode.
- Clone the repo
git clone https://github.com/oslabs-beta/Examin.git
- Install NPM packages
npm install
- Create a build directory
npm run build
- 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 -
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"] }
-
Run the Examin build using npm run dev
-
Navigate to the Examin panel in Chrome DevTools
- Must be in developer mode
- Revise import statements as needed
-
Add Generated tests into your application
- Add
__tests__
directory in root directory - Add test js file to
__tests__
directory - Run tests using
jest
orjest <filename>
- Add
- Editing import statements
- 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" }
- Add peerDependencies to your package.json file
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.