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.

changedSince runs specs related to files with no diff

See original GitHub issue

🐛 Bug Report

Using the --changedSince flag, Jest will run specs related to files with no current code changes (no diff) but which were previously committed.

The description of this flag is: Runs tests related to the changes since the provided branch. I would expect changes in this context to mean code changes between the current and specified revision, not each individual commit.

To Reproduce

Steps to reproduce the behavior:

  • Check out a new branch from master
  • Commit a change to any file (example.js) which has a related spec (example.test.js). Adding a comment will do.
  • Remove the change to this file & commit again.
  • Check that there are no current changes with git diff origin/master. There should be none.
  • Run jest --changedSince origin/master
  • Output will show that example.test.js was run, even though example.js has no changes.

Expected behavior

example.test.js does not run

Link to repl or repo (highly encouraged)

https://github.com/finn-orsini/jest-changed-since-bug-poc

  • Run yarn
  • Check out branch changed_since_no_changes (See PR showing no code changes here)
  • Run yarn test

Output will show that sum.test.js was run:

$ jest --changedSince origin/master
 PASS  src/__tests__/sum.test.js
  ✓ adds 1 + 2 to equal 3 (4ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.119s

Note that running git log --name-only --pretty=format: HEAD ^origin/master (the command run by jest-changed-files) on this branch will include sum.js since a comment was added and removed in previous commits.

envinfo

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 8.16.2 - ~/.nvm/versions/node/v8.16.2/bin/node
    Yarn: 1.21.1 - ~/.nvm/versions/node/v8.16.2/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.16.2/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
finn-orsinicommented, Jun 9, 2020

Sorry for the delay here, no excuse other than just totally dropped this from my radar.

I have a fork with what I think was a working fix from when this was originally posted, will double-check it tomorrow morning & post an update here.

Thanks for bearing with me!

3reactions
finn-orsinicommented, Jun 10, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I use --changedSince and --onlyChanged in jest?
I found --changedSince and --onlyChanged to be a little funky too. ... on every commit, Jest will run tests for related source files...
Read more >
How to Run Changed Specs First in a Pull Request - Cypress
Now that the local Git has the information for both branches, let's find the changed files between two branches using git diff command....
Read more >
Jest CLI Options
Run tests related to changed files based on hg/git (uncommitted files): ... Run tests that match this spec name (match against the name...
Read more >
Jest and the `--changedSince` flag in GitHub Actions CI
Now, this seems to be working perfectly - it'll diff changes between the current PR's HEAD and master , running only the tests...
Read more >
run tests on files changed since last commit - Google Groups
You could write a script to query git for the list of files that have changed since last commit, and pass the spec...
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