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

Added option to mock error during fetch #13

Merged
merged 1 commit into from
Sep 22, 2024
Merged

Conversation

sadkebab
Copy link
Contributor

Since fetch can throw errors on various conditions, I would expect this mock to give developers the ability to mock fetch error throws.

I implemented this feature by extending MockOptions with an optional throw property of type Error.
I also added a test to make sure that the mocked fetch call with throw an exception if the throw property is set.

@sadkebab
Copy link
Contributor Author

There may be some type errors in the test file because the current tsconfig.json configuration throws an error importing "bun:test".

If executed the test will run successfully, but VSCode will show few type errors here and there.

@sadkebab
Copy link
Contributor Author

Some suggestions to make contributing to this project easier from my experience making this PR:

Add default rules for a code formatter.

Consistency in coding style is very important in an open source project and having the rules defined as a configuration file for something like Prettier or Biome will make respecting the coding effortless for contributors

Fix the tsconfig.json

I was able to make the errors in the test file disappear by changing includes and excludes inside tsconfig.json but I didn't push those changes in the PR since the issue is unrelated to the content of this PR.

Add some simple contribution guidelines

The project structure is trivial but having a guideline on how to start contributing with a predictable setup process will make it easier for everybody.

I will be happy to open a new PR that will satisfy these concern if we discuss and agree on how to structure coding style rules beforehand.

@DRFR0ST
Copy link
Owner

DRFR0ST commented Sep 21, 2024

Hey, thanks for the contribution! I'm super happy that you've brought up the contribution guidelines and default formatting rules. I have already started work on the two topics.

Sorry for the misconfigured tsconfig.json file. Would you mind creating a PR for the change that fixes the errors appearing in the test files?

Copy link
Owner

@DRFR0ST DRFR0ST left a comment

Choose a reason for hiding this comment

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

LGTM 👌🏻

Thanks for the contribution! 🎉

@DRFR0ST
Copy link
Owner

DRFR0ST commented Sep 21, 2024

@sadkebab would you like to contribute to the Biome set up PR?
#15

@DRFR0ST DRFR0ST merged commit 63b7235 into DRFR0ST:main Sep 22, 2024
1 check passed
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