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
  • Merge requests
  • !12599

Fix writing an absolute path to modulePaths in Jest config when ejecting

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/mkarajohn/fix-absolute-paths-in-jest-config-modulePaths into main Jul 19, 2022
  • Overview 3
  • Commits 2
  • Pipelines 0
  • Changes 3

Created by: mkarajohn

Resolves #8965 (closed)

Problem & Cause

As described in the linked issue, when a CRA project is ejected, the modulePaths entry of the jest config includes an array of absolute paths, if a baseUrl is defined in the tsconfig.json or jsconfig.json.

The array is created here exported as additionalModulePaths.

Since this exported array of additionalModulePaths is also used in the webpack.config.js here, where absolute paths are in fact needed, we cannot be directly modifying the way the additionalModulePaths array contents are created.

Solution

What this PR does in order to fix the issue, is to translate the absolute paths to relative ones in the createJestConfig.js file here, since adding absolute paths in the modulePaths is problematic, in cases such as CI pipelines, or simply someone else trying to run the tests on their own machine. Making them relative to the rootDir solves any issues.

Before: image

After: image

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mkarajohn/fix-absolute-paths-in-jest-config-modulePaths