caMicroscope icon indicating copy to clipboard operation
caMicroscope copied to clipboard

Unit Test : Add User Function Test

Open barchakuz opened this issue 11 months ago • 2 comments

Unit Test 1 : Add User function

Summary

This pull request adds test code using the Jest framework for the addUser function in the Signup.js file. The tests cover various scenarios including email validation, different user types, API calls, and error handling.

Motivation

The motivation behind this pull request is to ensure the correctness and reliability of the addUser function by implementing comprehensive test coverage. This helps in catching bugs early and ensuring that the function behaves as expected under different conditions.

Testing

The test code has been written using Jest and includes mocks for external dependencies like document.getElementById and fetch to simulate user input and API requests. Each test case covers a specific scenario, and the test suite has been run using the Jest CLI to verify the functionality.

barchakuz avatar Mar 24 '24 22:03 barchakuz

Hi! This looks interesting! How did you run/set this for testing?

birm avatar Mar 29 '24 21:03 birm

@birm I've integrated Jest, a JavaScript testing framework, for unit testing. I've utilized a custom script in test.signup to automate form submission. The values for the form are visible within the test script.

barchakuz avatar Mar 29 '24 21:03 barchakuz