Skip to content

Fix failBuild() testing #36

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

Merged
merged 1 commit into from
Nov 14, 2020
Merged

Fix failBuild() testing #36

merged 1 commit into from
Nov 14, 2020

Conversation

ehmicky
Copy link

@ehmicky ehmicky commented Nov 13, 2020

Under the hood, utils.build.failBuild() is throwing an error.
However, in tests, it is mocked with an empty function. This means the control flow continues because the code does not have any return statement after failBuild(). This means tests end up in odd situation where they are reaching lines of code that should never been hit in production.

This PR tries to fix this by:

  • Adding return statements after utils.build.failBuild()
  • Instead of mocking utils.build.failBuild(), replacing it with a simple function that throws an error. The tests then need to assert that an error is thrown from the async onPreBuild function, which is done in Jest with await expect(onPreBuild(...)).rejects.toThrow('error message'), as opposed to looking for mock calls.

@ehmicky ehmicky added the type: bug code to address defects in shipped code label Nov 13, 2020
@ehmicky ehmicky self-assigned this Nov 13, 2020
Copy link

@lindsaylevine lindsaylevine left a comment

Choose a reason for hiding this comment

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

this is awesome, much to learn <3 a suggestion to be made possibly to nimbella since i took the mock failBuild logic from them 🌚

@ehmicky ehmicky merged commit e456a79 into main Nov 14, 2020
@ehmicky ehmicky deleted the bug/fix-fail-build branch November 14, 2020 20:39
ascorbic added a commit that referenced this pull request Oct 5, 2021
* fix: include base static redirect for i18n sites too

* fix: update snapshot
serhalp pushed a commit that referenced this pull request Apr 5, 2024
…res (#36)

* fix: fixes an issue with next and npm workspaces on the testing fixtures

* fix: issues from main branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants