“ReferenceError: document is not defined” when trying to test a create-react-app project

前端 未结 4 2291
醉话见心
醉话见心 2021-02-18 13:42

This is my __tests__/App.js file:

import React from \'react\';
import ReactDOM from \'react-dom\';
import App from \'../src/containers/App\';

it(\'         


        
4条回答
  •  执笔经年
    2021-02-18 14:28

    Placing the comment at the top of your unit-test source

    /**
     * @jest-environment jsdom
     */
    

    signals jest to mock document and window.

提交回复
热议问题