Implement new tests and fix validation code. Also some coverage information and details. #46
Implement new tests and fix validation code. Also some coverage information and details. #46R-aidla wants to merge 1 commit into
Conversation
- Add missing password param check - Add missing username param check - Update app.mock.test.js to match app.test.js tests - Update app.test.js tests to test for business requirements - Clean up comments from test files - Perform coverage tests
API & Mocked Tests and CoveragePurpose: Validate README requirements for regular tests, mocked email tests, coverage, and runtime comparison. |
Additional ContextBug Fix Identified During TestingWhile running the test suite, an issue was discovered where the username and password validation logic did not handle This resulted in runtime errors such as: TypeError: Cannot read properties of undefined (reading 'length')This also caused some tests to hang longer than expected, since the request would fail without returning a proper response. Fix implemented:
This fix should (in theory) prevent server crashes on malformed requests and ensure consistent validation across all input fields. |
Summarized commits:
Coverage
Statements: 100%
Branches: 100%
Functions: 100%
Lines: 100%
All files are fully covered, including:
Observations
There is a significant performance gap between mocked and non-mocked tests due to
non-mocked running validateEmail.js that has a 2 second delay built-inthe non-mocked validateEmail.js script calling out to a (simulated) external service to check emails. The mocked test is giving an expected response back to the test without calling out to the external service, removing any potential delays.Integration tests currently take ~2 seconds per request, which may indicate:
Artificial delays in validation (a simple 2 second delay simulating high demand services)Detailed tests and time
Tests were ran at 20:00 27.04.2026
PASS validation/validateUsername.test.js (0.014 s)
PASS validation/validatePassword.test.js (0.019 s)
PASS ./app.mock.test.js (0.684 s)
PASS validation/validateEmail.test.js (10.589 s)
PASS ./app.test.js (42.968 s)
Test Suites: 5 passed, 5 total
Tests: 64 passed, 64 total
Snapshots: 0 total
Time:43.279 s, estimated 44 s
Ran all test suites.