question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setupFilesAfterEnv is empty with --showConfig, despite being set in package.json

See original GitHub issue

🐛 Bug Report

I’m running jest and my setupFilesAfterEnv is being ignored.

...
  "jest": {
    "setupFilesAfterEnv": [
      "jest-extended",
      "./jest.setup.js"
    ]
  },
...
$ NODE_ENV=test jest --showConfig
{
  "configs": [
    {
      "automock": false,
      "cache": true,
      "cacheDirectory": "/private/var/folders/lr/1wlz_4jj6h512dpg3c58rrxw0000gn/T/jest_dx",
      "clearMocks": false,
      "coveragePathIgnorePatterns": [
        "/node_modules/"
      ],
      "cwd": "/Users/vadorequest/dev/next-right-now",
      "detectLeaks": false,
      "detectOpenHandles": false,
      "errorOnDeprecated": false,
      "extraGlobals": [],
      "forceCoverageMatch": [],
      "globals": {
        "ts-jest": {
          "tsConfig": "tsconfig.jest.json"
        }
      },
      "haste": {
        "computeSha1": false,
        "throwOnModuleCollision": false
      },
      "moduleDirectories": [
        "node_modules"
      ],
      "moduleFileExtensions": [
        "js",
        "json",
        "jsx",
        "ts",
        "tsx",
        "node"
      ],
      "moduleNameMapper": [],
      "modulePathIgnorePatterns": [
        "cypress"
      ],
      "name": "a5d3558a4f13ae2e5c693ddddf111044",
      "prettierPath": "prettier",
      "resetMocks": false,
      "resetModules": false,
      "restoreMocks": false,
      "rootDir": "/Users/vadorequest/dev/next-right-now",
      "roots": [
        "/Users/vadorequest/dev/next-right-now"
      ],
      "runner": "jest-runner",
      "setupFiles": [],
      "setupFilesAfterEnv": [],
      "skipFilter": false,
      "snapshotSerializers": [],
      "testEnvironment": "/Users/vadorequest/dev/next-right-now/node_modules/jest-environment-node/build/index.js",
      "testEnvironmentOptions": {},
      "testLocationInResults": false,
      "testMatch": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[tj]s?(x)"
      ],
      "testPathIgnorePatterns": [
        "/node_modules/"
      ],
      "testRegex": [],
      "testRunner": "/Users/vadorequest/dev/next-right-now/node_modules/jest-jasmine2/build/index.js",
      "testURL": "http://localhost",
      "timers": "real",
      "transform": [
        [
          "^.+\\.tsx?$",
          "/Users/vadorequest/dev/next-right-now/node_modules/ts-jest/dist/index.js",
          {}
        ]
      ],
      "transformIgnorePatterns": [
        "/node_modules/"
      ],
      "watchPathIgnorePatterns": []
    }
  ],
  "globalConfig": {
    "bail": 0,
    "changedFilesWithAncestor": false,
    "collectCoverage": false,
    "collectCoverageFrom": [],
    "coverageDirectory": "/Users/vadorequest/dev/next-right-now/coverage",
    "coverageProvider": "babel",
    "coverageReporters": [
      "json",
      "text",
      "lcov",
      "clover"
    ],
    "detectLeaks": false,
    "detectOpenHandles": false,
    "errorOnDeprecated": false,
    "expand": false,
    "findRelatedTests": false,
    "forceExit": false,
    "json": false,
    "lastCommit": false,
    "listTests": false,
    "logHeapUsage": false,
    "maxConcurrency": 5,
    "maxWorkers": 7,
    "noStackTrace": false,
    "nonFlagArgs": [],
    "notify": false,
    "notifyMode": "failure-change",
    "onlyChanged": false,
    "onlyFailures": false,
    "passWithNoTests": false,
    "projects": [],
    "rootDir": "/Users/vadorequest/dev/next-right-now",
    "runTestsByPath": false,
    "skipFilter": false,
    "testFailureExitCode": 1,
    "testPathPattern": "",
    "testSequencer": "/Users/vadorequest/dev/next-right-now/node_modules/@jest/test-sequencer/build/index.js",
    "updateSnapshot": "new",
    "useStderr": false,
    "watch": false,
    "watchAll": false,
    "watchman": true
  },
  "version": "26.0.1"
}

To Reproduce

It used to work, today it doesn’t and I don’t know when it broke.

Expected behavior

Should print Jest env has been enhanced - See "./jest.setup.js" from ./jest.config.js

Link to repl or repo (highly encouraged)

Commit where I noticed the bug: https://github.com/UnlyEd/next-right-now/pull/86/commits/fed97cde17e6aeb4f824a8f72ee37faa6e1f7fbe

git clone https://github.com/UnlyEd/next-right-now.git
cd next-right-now && git checkout fed97cde17e6aeb4f824a8f72ee37faa6e1f7fbe
yarn test:config

envinfo

  System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 14.3.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  npmPackages:
    jest: 26.0.1 => 26.0.1 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
SimenBcommented, Jun 4, 2020

Thanks @Vadorequest, I’ve opened up #10124 for this

0reactions
github-actions[bot]commented, May 11, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect version of jest trying to run jest - Stack Overflow
I have a package.json file specifying the version of jest I would like to ... Validation Warning: Unknown option "setupFilesAfterEnv" with ...
Read more >
Top 5 jest-config Code Examples - Snyk
Learn more about how to use jest-config, based on jest-config code examples created from the most popular ways it is used in public...
Read more >
jest-worker | Yarn - Package Manager
The module works by providing an absolute path of the module to be loaded in all forked processes. All methods are exposed on...
Read more >
Testing JavaScript Flashcards - Quizlet
It's a mock function that can inspect a function being indirectly called ... In Node >= v13 save file as .mjs & put...
Read more >
jest mock cache manager
Set the current system time used by fake timers. ... variable name with mock which will prevent it from being hoisted i.e. Returns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found