/react-todo

Simple React Todo App

Primary LanguageJavaScript

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