Scaffold-Stark / scaffold-stark-2

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

[TEST] Add unit tests for `useScaffoldWriteContract` and `useScaffoldWriteContract` #291

Closed metalboyrick closed 1 month ago

metalboyrick commented 1 month 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
ShantelPeters commented 1 month ago

Hi @metalboyrick i will love to work on this issue. Kindly assign please

onlydustapp[bot] commented 1 month ago

Hi @ShantelPeters! 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 1 month ago

Hello @metalboyrick I'm a frontend and also a Blockchain developer. I will love to work on this

onlydustapp[bot] commented 1 month ago

Hi @CollinsC1O! 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 1 month 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 1 month 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 and testing frontend applications

How I plan on tackling this issue

I understand that unit tests are needed for the specified hooks to facilitate future refactoring and validate features. Set Up the Testing Framework:

I will use Vitest to run the unit tests and refer to the Vitest documentation for guidance on syntax and usage. Import Required Testing Tools:

I will ensure that I import the necessary hooks testing tools from @testing-library/react to effectively handle the testing of hooks. Review Testing Instructions:

I will consult the README.md file for detailed instructions on executing the tests, ensuring that I follow the project’s established procedures. Isolate Tests When Necessary:

If I need to focus on specific tests during development, I will use it.only() for isolation. However, I will remember to remove it before submitting my PR to avoid leaving any isolated tests. Mock Dependencies When Needed:

I will mock any necessary dependencies or external data to ensure the tests function correctly in various environments, not just on my device. Seek Clarification If Uncertain:

If I am unsure about any features of the code units that require testing, I will refer to the documentation or reach out for assistance on the issue page or via the Telegram group.

I will ensure that my tests achieve at least 70% code coverage. When I submit my PR, I will include a screenshot of the coverage results as proof that I have met this requirement.

gregemax commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have solid experience in JavaScript and unit testing using Vitest. I’ve previously worked on testing React hooks, focusing on writing robust tests to ensure functionality and reliability. My familiarity with testing best practices will enable me to effectively implement unit tests for useScaffoldWriteContract.

How I plan on tackling this issue

I would start by reviewing the useScaffoldWriteContract hooks to understand their functionality, then write comprehensive unit tests using Vitest, covering various scenarios and edge cases. I’d mock any necessary dependencies and ensure the tests achieve at least 70% code coverage, submitting a coverage report with the PR.

No-bodyq commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a fullstack and blockchain dev with experience in writing test 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.

Jemiiah commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

@metalboyrick @Nadai2010 @0xquantum3labs I would love to work on this issue I'm a frontend web 3 developer with over 50 + contribution to only dust

How I plan on tackling this issue

Understand the Problem: Before delving into the code, I would thoroughly review the issue description to grasp the specific requirements for adding unit tests for the useScaffoldWriteContract code.

Use vitest for Unit Testing: As per the project's guidelines, I would familiarize myself with the vitest testing framework by referring to their documentation at vitest.dev. This would provide me with insights into the syntax and methodologies required for running the unit tests.

Import Necessary Testing Tools: After understanding the testing requirements, I'd ensure to import the hooks testing tools from @testing-library/react, which are essential for testing React hooks.

Review Execution Instructions: I would thoroughly review the project's README.md file for detailed instructions on executing the tests. Understanding and following these instructions are crucial for successful implementation of the tests.

Isolate Tests When Needed: If necessary, I would make use of it.only() to isolate specific tests during development. However, it's crucial to remember to remove it before submitting the Pull Request (PR) to maintain the integrity of the test suite.

Mock Dependencies: Whenever necessary, I'd utilize mocking techniques to create isolated test environments. This ensures that the tests are not dependent on external factors and function consistently across different setups.

Understand Code Unit Features: I would ensure that I am clear on the features and functionality of the useScaffoldWriteContract code units that require testing. If there are any uncertainties, I would refer to the documentation or seek clarification through the issue page or relevant communication channels.

Achieve Code Coverage: With a focus on code quality, I would aim to achieve at least 70% code coverage with the unit tests. This is crucial to ensure comprehensive validation of the code's functionality and maintain its reliability.

Nadai2010 commented 1 month ago

All yours @NueloSE

metalboyrick commented 1 month ago

Hi @NueloSE , any updates on this issue?

NueloSE commented 1 month ago

Hi @NueloSE , any updates on this issue?

I was having issue setting up the environment but resolved now.

current challenge is the title of my task Add unit tests for useScaffoldWriteContract and useScaffoldWriteContract the useScaffoldWriteContract is repeated twice

am I suppose to just test only useScaffoldWriteContract

metalboyrick commented 1 month ago

@NueloSE Sorry for the late reply, i meant useScaffoldMultiWriteContract as the other one.

Feel free to find us in the telegram group in case you have any questions (especially urgent ones) since sometimes the notifications don't come through here, thanks!