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.

`jest --only-changed` ignores changes to module mocks

See original GitHub issue

🐛 Bug Report

jest --only-changed does not take mocks into consideration when choosing the tests to run.

To Reproduce

Steps to reproduce the behavior (see example repo):

  • module ./a depends on module ./b
  • module ./b is mocked in the test of './a`
  • you change the mock of module ./b

Expected behavior

Test of module ./a is run when running jest --only-changed.

The success of the test depends on changes of the mock file - so changing the mock should trigger the test - the same way as changing ./b directly does.

The scenario is not uncommon - could happen when someone is extending the functionality of ./b, or works on another module that depends on it.

Link to repl or repo

https://github.com/tomasz-sodzawiczny/jest-only-changed-vs-mocks

envinfo

Probably not important, but:

System:
    OS: macOS 10.14.5
    CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 12.4.0 - ~/.nvs/node/12.4.0/x64/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvs/node/12.4.0/x64/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
brapifracommented, Aug 17, 2020

I see an open PR for this. Any updates? @petevdp @SimenB I’d love to see this merged soon 🙂

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

Bypassing module mocks - Jest
Jest allows you to mock out whole modules in your tests, which can be useful for testing if your code is calling functions...
Read more >
jest(1) — jest — Debian unstable - Debian Manpages
Runs tests related to the current changes and the changes made in the last commit. Behaves similarly to `--onlyChanged`. [boolean]. -- ...
Read more >
jest-meluski - npm
Mock by Default: Jest automatically mocks JavaScript modules, ... recommended to use jest -o or jest --onlyChanged which will find tests related to...
Read more >
Manual mock not working in with Jest - Stack Overflow
Module mocks are hoisted when possible with babel-jest transform, so this will result in mocked module: import ModuleA from ".
Read more >
Unit Testing - Webpack from Nothing
If `onlyChanged` is set by default, running jest with `--all` will force Jest to run all tests instead of running only tests related...
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