Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Petevdp/resolve mock dependencies #8951

Closed
wants to merge 3 commits into from
Closed

Petevdp/resolve mock dependencies #8951

wants to merge 3 commits into from

Conversation

petevdp
Copy link
Contributor

@petevdp petevdp commented Sep 12, 2019

Summary

fixes #8907

DependencyResolver.resolve resolves the functional dependencies for a given file, but it doesn't include potential mock dependencies. This means that, as the issue lays out, updates to mocks won't register as an affecting change for tests.

The changes I made will include mocks with names matching any functional dependency during the resolution process. Note this won't take into account any in-code dependency declarations, but it solves the problem in an unobtrusive way.

Test plan

I added a unit test describing this new requirement, and it passes along with all previously passing tests. There are some failing tests when running the full test suite, but they appear to be pre-existing.

Here's the output of running the dependency resolver tests:

 PASS  packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts
  ✓ resolves no dependencies for non-existent path (255ms)
  ✓ resolves dependencies for existing path (13ms)
  ✓ includes the mocks of dependencies as dependencies (8ms)
  ✓ resolves dependencies for scoped packages (7ms)
  ✓ resolves no inverse dependencies for empty paths set (8ms)
  ✓ resolves no inverse dependencies for set of non-existent paths (9ms)
  ✓ resolves inverse dependencies for existing path (9ms)
  ✓ resolves inverse dependencies from available snapshot (10ms)

Test Suites: 1 passed, 1 total
Tests:       8 passed, 8 total
Snapshots:   0 total
Time:        0.791s, estimated 1s
Ran all test suites matching /\/home\/pete\/Code\/contributions\/jest\/jest\/packages\/jest-resolve-dependencies\/src\/__tests__\/dependency_resolver.test.ts/i.

A test of the scenario given in the referenced issue also fixes the problem.

This is my first pull request, so apologies in advance for any miss-steps. I'll do my best to correct them quickly!

@petevdp petevdp closed this Sep 12, 2019
@petevdp petevdp deleted the petevdp/resolve-mock-dependencies branch September 12, 2019 22:24
@github-actions
Copy link

This pull request 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jest --only-changed ignores changes to module mocks
1 participant