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

Fix "reset": also reset module alias names #75

Merged
merged 1 commit into from
Sep 30, 2019

Conversation

Kehrlann
Copy link
Collaborator

When working on some tests I had weird issues: tests started failing when I added a describe block.

Several things where happening:

  1. We import TWO versions of module-alias in the tests. One for all tests, and one for the specific test when module-alias package is nested (looking up __dirname/../../). Each of these modules registers their own handlers, and have to be reset separately.
  2. Also, "reset" did not clear the moduleAliasNames, which confused module-alias to think an alias was registered when it was actually not in the moduleAliases object.

As part of this PR, I also cleaned up the tests:

  • Import module-alias once for all tests, not before every test
  • Move the Custom handler function describe block within the test suite: it reference the "moduleAlias" variable which is initialized by the "before" block. Also moved "moduleAlias" within the top-level describe. We could have imported it directly above the describe, but since it's the thing under test, that looks more explicit to me.

@ilearnio
Copy link
Owner

I love it! ❤️

@ilearnio ilearnio merged commit 07a6b80 into dev Sep 30, 2019
@ilearnio ilearnio deleted the fix/reset-moduleAliasNames branch September 30, 2019 17:18
@ilearnio ilearnio restored the fix/reset-moduleAliasNames branch September 30, 2019 17:18
@ilearnio ilearnio deleted the fix/reset-moduleAliasNames branch September 30, 2019 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants