Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #583
Closed
Open
Issue created Sep 05, 2016 by Administrator@rootContributor

Cannot import a jest.mock() when running tests with --coverage

Created by: gaelollivier

Steps:

  • Create a new app: create-react-app my-app
  • Create a new file that does a jest.mock(), ex:

src/mock.js

jest.mock('react-dom', () => {})
  • Import this file in App.test.js:

src/App.test.js

import './mock.js'

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
...
  • Run the tests with --coverage:
npm run test -- --coverage

I get this error: image

I can't find a workaround for this, there's no documentation on how to import mocks so I can reuse them.

@cpojer It may be a Jest issue ? Am I doing something wrong ?

Assignee
Assign to
Time tracking