Giter VIP home page Giter VIP logo

jest-enzyme-example's Introduction

Build Status Known Vulnerabilities

Jest with Enzyme Example

This is an example project built to demonstrate using enzyme from Airbnb with Jest.

Usage

Run npm install after cloning this repository to download all the required packages for the project.

Run npm start to start the server locally:

npm start

The start script has a corresponding prestart script which will test and compile the code for you before starting the server. for full details, you can view the configuration in package.json.

Jest Config

One of the powerful feature of Jest is that it automatically mocks dependencies as default. However, this means that we need to make sure we unmock enzyme in order to be able to use it successfully. With this in mind, below is the Jest config required in package.json:


"jest": {
            ...

            "unmockedModulePathPatterns": [
               "./node_modules/react",
               "./node_modules/enzyme"
             ]
         }
    

Project Structure

Overview

.
├── /__tests__/              # Folder containing tests
│
├── /client/                 # The source code of the application
│   ├── /components/         # React components
│   ├── /compiled.js         # Compiled react components generated using Browserify
│   ├── /index.html          # root HTML file for inject
│   └── /main.js             # Root react file used for compile
│
├── .babelrc                 # Contains Babel configuration
├── .eslintrc                # Contains ESLint configuration
├── .jscsrc                  # Contains JSCS configuration
├── .eslintignore            # Contains files to be ignored by ESLint
├── .gitignore               # Defines which files should not be backed up to git
├── package.json             # Contains the list of 3rd party libraries and utilities used, as well as all npm scripts to run the project
├── server.js                # Node server config file
├── setup-jasmine-env.js     # Jasmine Reporters config file
└── test-results.xml         # Code coverage report generated for CI

jest-enzyme-example's People

Contributors

joedevibm avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.