Skip to content

Ejecting writes an absolute path Jest modulePath config  #8965

@sdemjanenko

Description

@sdemjanenko

Describe the bug

When using typescript, run eject and then look at the Jest config in package.json. The modulePaths array will have an absolute path instead of being relative to the root dir (e.g. /home/stephen/my-app/src vs <rootDir>/src).

Did you try recovering your dependencies?

This is reproducible from a brand new install.

Which terms did you search for in User Guide?

There is no reference to modulePaths in the user guide.

Environment

Environment Info:

  current version of create-react-app: 3.4.1
  running from /home/stephen/.npm/_npx/1849/lib/node_modules/create-react-app

  System:
    OS: Linux 4.4 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  Binaries:
    Node: 12.16.1 - /usr/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-scripts: 3.4.1 => 3.4.1
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. yarn run eject
  2. Open package.json and look for Jest's modulePaths

Expected behavior

I expected modulePaths to be ["<rootDir>/src"]

Actual behavior

modulePaths was ["/home/stephen/my-app/src"]

Reproducible demo

https://github.com/sdemjanenko/cra-typescript-eject-bug

Follow the Readme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions