Scaffold-Stark / scaffold-stark-2

Open source forkable Starknet dev stack
https://www.scaffoldstark.com/
79 stars 73 forks source link

[TEST] Add unit tests for `useScaffoldContract` and `useScaffoldReadContract` #292

Open metalboyrick opened 4 days ago

metalboyrick commented 4 days ago

Issue Overview

Unit tests required for the indicated hooks to ease future refactoring and feature validations.

Proposed Solutions or Ideas (more like tips and reminders)

Code Coverage

IMPORTANT - When submitting a PR, please provide a screenshot of the coverage for the specific units you are working on. We would like to achieve >= 70 % code coverage.

Happy Hacking!

Example:

image
od-hunter commented 3 days ago

Hi @metalboyrick Please can I work on this when od hack starts?

onlydustapp[bot] commented 3 days ago

Hi @od-hunter! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

CollinsC1O commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello I'm a frontend and also a blockchain developer and I would love to hop on this issue

NueloSE commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i am a frontend developer with experience in developing frontend application developer and testing. kindly assign me

How I plan on tackling this issue

Set Up Unit Tests:

I will write unit tests for the hooks using Vitest as the testing framework. I'll refer to the Vitest documentation for syntax, and if I have experience with Jest, it should be easy to adapt. Test Hooks:

I will import testing tools from @testing-library/react to specifically test React hooks. Running Tests:

I'll refer to the project's README.md for instructions on executing tests. If needed, I can use it.only() to isolate specific tests for debugging but will remove it before submitting the PR. Mocking and Cross-Device Testing:

I will mock any necessary components or data for the tests and ensure that the tests work across devices, not just on my own. Ask for Help if Needed:

If I’m unsure about any part of the code or the hooks' functionality, I will check the documentation or ask questions on the issue page or Telegram group. Code Coverage:

I will aim to achieve at least 70% code coverage for the hooks I am testing. Before submitting the PR, I’ll provide a screenshot of the coverage results to show the achieved percentage.

gregemax commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Tell us about your background and how it can be leveraged:

I have experience in JavaScript and testing frameworks, particularly Vitest. I’ve previously written unit tests for React hooks, ensuring code quality and reliability. My familiarity with testing best practices and coverage metrics will enable me to effectively implement comprehensive tests for useScaffoldWriteContract.

How I plan on tackling this issue

I would start by reviewing the existing hooks to understand their functionality, then write unit tests using Vitest, focusing on edge cases and mocking as needed. I’d ensure the tests achieve at least 70% code coverage and run them to confirm functionality, providing a coverage report with the PR.

No-bodyq commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a fullstack dev with experience in writing tests for web applications as well as smart contracts

How I plan on tackling this issue

I'll start by reviewing the Vitest documentation to familiarize myself with the syntax and best practices for writing unit tests. Next, I'll identify the specific hooks that need unit tests and compile a list of them. For each identified hook, I'll write unit tests using Vitest, adhering to its syntax and utilizing @testing-library/react for testing hooks. I'll follow the instructions in the README.md file to understand how to run the tests. If I need to isolate specific tests, I'll use it.only() to run those tests individually, but ensure it's removed before submitting the PR. Where mocking is necessary, I'll implement mocking libraries to avoid dependencies on external factors in the tests.

ScottyDavies commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have a strong background in software development and testing, particularly with React and state management hooks

How I plan on tackling this issue

To tackle the issue, I would:

Review the hooks' implementation and related documentation to understand their functionality and edge cases.

Set Up Testing Environment: Ensure the testing environment is ready by following the README.md instructions for executing tests using Vitest.

Write Tests: Create unit tests for each hook, using the appropriate syntax from Vitest and @testing-library/react. Focus on testing various scenarios, including edge cases.

Mock Dependencies: Use mocking where necessary to isolate the hooks and ensure tests run consistently across different environments.

Code Coverage: Regularly check code coverage during development to ensure it meets the ≥ 70% requirement, providing a screenshot when submitting the PR.

Isolate Tests: Utilize it.only() for isolating tests during development, ensuring to remove it before final submission.

josephchimebuka commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, I am Joseph I am a software developer developer and blockchain developer and I am also an active contributor here on only dust here is my profile https://app.onlydust.com/u/josephchimebuka.

How I plan on tackling this issue

I will start by reviewing the Vitest documentation.

Then, I will set up the testing environment as outlined in the README.md, including installing @testing-library/react for testing React hooks. I'll proceed by writing unit tests, using it.only() to isolate specific tests for debugging when necessary, and mocking external dependencies to ensure reliable tests.

Afterward, I will run the tests across different environments or machines to verify they work universally, not just on my device. Once confirmed, I will remove any it.only() instances and submit the PR with passing tests and proper mocking in place.in 3-4 days

Nadai2010 commented 2 days ago

All yours @CollinsC1O