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

Enable and fix babel-register tests #7487

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Enable and fix babel-register tests #7487

merged 1 commit into from
Mar 5, 2018

Conversation

danez
Copy link
Member

@danez danez commented Mar 4, 2018

Q                       A
Fixed Issues? Fixes #7477
Patch: Bug Fix? n
Major: Breaking Change? n
Minor: New Feature? n
Tests Added + Pass? Yes
Documentation PR
Any Dependency Changes?
License MIT

I changed the base register test to mock pirates and source-map support and just test it calls these libs correctly.
The cache tests worked after fixing the cache invalidation with jest.

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 4, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7076/

@danez danez added the PR: Internal 🏠 A type of pull request used for our changelog categories label Mar 4, 2018
describe("cache", () => {
let load, get, save;

beforeEach(() => {
// Since lib/cache is a singleton we need to fully reload it
delete require.cache[require.resolve("../lib/cache")];
jest.resetModuleRegistry();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this run automatically by jest before each test? (jestjs/jest#587 (comment))

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it changed? Or it is only run once for each test file? At least the tests weren't working without.

Copy link
Contributor

@SimenB SimenB Mar 5, 2018

Choose a reason for hiding this comment

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

Should be jest.resetModules(). resetModuleRegistry is a deprecated alias and not publicly documented.

See https://github.com/facebook/jest/blob/0b076cdfd6020810fc05fb0f26cdca30d688ead1/packages/jest-runtime/src/index.js#L830-L831

It is not run automatically between tests in a single suite, but each suite (file) is run in isolation

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks, I somewhere found it documented, but now I can't find it anymore :) Will fix it.

@danez danez merged commit f43bf7f into master Mar 5, 2018
@danez danez deleted the register-tests branch March 5, 2018 09:47
aminmarashi pushed a commit to aminmarashi/babel that referenced this pull request Mar 17, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix and reenable babel-register tests
5 participants