Skip to content

--onlyChanged in precommit is failing #5139

@marcelmokos

Description

@marcelmokos

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Our project contains also non-javascript code.
When I run jest --onlyChanged in husky precommit, I am receiving exit code 1 when no tests found related to files changed since the last commit.

This is disabling commits for other than javascript code with the tests in the repository.
We can not move to version higher than 22.0 until this will be fixed. For now, we have to stay on 21.2.1. This incorrect behavior is present from version 22.0.0.

terminal output jest v21.2.1

yarn run v1.3.2
$ jest --onlyChanged
No tests found related to files changed since last commit.
Run Jest without `-o` or with `--all` to run all tests.
✨  Done in 1.61s.

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

package.json

"test:changed": "yarn test --onlyChanged --silent --runInBand",
"precommit": "lint-staged && yarn test:changed",

terminal output jest v22.0.3

yarn run v1.3.2
$ jest --onlyChanged
No tests found related to files changed since last commit.Press `a` to run all tests, or run Jest with `--watchAll`.
error Command failed with exit code 1.

What is the expected behavior?
Exit code should be 0. When changed files do not have related test files.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

jest 22.0.3

"engines": {
    "node": ">=8", // v8.5.0
    "npm": ">=5", // 5.5.1
    "yarn": ">=1" // 1.3.2
},

MacOS High Siera

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions