caMicroscope
caMicroscope copied to clipboard
Unit Test : Add User Function Test
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.
Hi! This looks interesting! How did you run/set this for testing?
@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.