uudashr / react-todo

Simple React Todo App

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Todo App

Simple React Todo Application

Reference Documentation

  1. Jest Documentation
  2. Testing Library Documentation
  3. How to fetch data with React Hooks

Testing

jsdom

In order to jsdom to works, se need to mock the matchMedia. Need to add script on setupTests.js

Object.defineProperty(window, 'matchMedia', {
  value: () => {
    return {
      matches: false,
      addListener: () => { },
      removeListener: () => { }
    };
  }
});

Ant Design

Add below to package.json tp ensure the antd can works with testing.

{
  "jest": {
    "transformIgnorePatterns": [
      "/node_modules/(?!antd|@ant-design|rc-.+?|@babel/runtime).+(js|jsx)$"
    ],
  }
}

Mock

Add below to package.json to ensure the test Jest mock / jest.fn() can works

{
  "jest": {
    "resetMocks": false
  }
}

Ref: jestjs/jest#9131

About

Simple React Todo App


Languages

Language:JavaScript 97.2%Language:HTML 2.2%Language:CSS 0.6%