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

Add restoreMocks config to fix #3580 #5327

Merged
merged 4 commits into from
Jan 16, 2018

Conversation

gricard
Copy link
Contributor

@gricard gricard commented Jan 16, 2018

Summary

Added a restoreMocks option to the Jest configuration as requested in #3580.

Test plan

Integration tests for this configuration option are included.

@codecov-io
Copy link

codecov-io commented Jan 16, 2018

Codecov Report

Merging #5327 into master will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5327      +/-   ##
==========================================
- Coverage   61.25%   61.21%   -0.04%     
==========================================
  Files         205      205              
  Lines        6896     6900       +4     
  Branches        3        3              
==========================================
  Hits         4224     4224              
- Misses       2671     2675       +4     
  Partials        1        1
Impacted Files Coverage Δ
packages/jest-config/src/defaults.js 100% <ø> (ø) ⬆️
packages/jest-config/src/normalize.js 93.1% <ø> (ø) ⬆️
packages/jest-config/src/valid_config.js 100% <ø> (ø) ⬆️
packages/jest-config/src/index.js 25.92% <ø> (ø) ⬆️
packages/jest-jasmine2/src/index.js 5.47% <0%> (-0.16%) ⬇️
...ircus/src/legacy_code_todo_rewrite/jest_adapter.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7743c09...1ebb4f0. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments. Also, please update the changelog

test('first test', () => {
jest.spyOn(localClass, 'test').mockImplementation(() => 'ABCD');
expect(localClass.test()).toEqual('ABCD');
expect(localClass.test.mock.calls.length).toBe(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.toHaveBeenCalledTimes(1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the others

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. I left that the way it was in the tests for resetMocks. I wasn't sure if it was using that older style for a specific reason or not. Fixed.

As for the changelog, would this be correct? The changes touch jest-cli, jest-config, jest-jasmine2, etc. so I'm not sure which one to place in the beginning of the line. I went with jest-config since it's more related to the config.

* `[jest-config]` Add restoreMocks config option.
  ([#5327](https://github.com/facebook/jest/pull/5327))

@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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants