Skip to content

Test cases setup#23

Merged
amberkamboj77 merged 7 commits intomainfrom
feat/jest-setup
Jul 14, 2025
Merged

Test cases setup#23
amberkamboj77 merged 7 commits intomainfrom
feat/jest-setup

Conversation

@amberkamboj77
Copy link
Contributor

@amberkamboj77 amberkamboj77 commented Jul 10, 2025

📄 Description

This PR introduces Jest setup for testing screens. This PR covers test cases for login-id screen on scenarios like error handling, CAPTCHA display, social login buttons, passkey authentication, and form validation.

Uses Jest manual mocks to replace Auth0 SDK imports with test data so tests don't make real API calls.

♻️ Changes

  1. Jest Configuration - jest.config.cjs with module mapping and test environment setup
  2. Manual Mocks - src/__mocks__/@auth0/auth0-acul-js/login-id.ts replaces SDK with test data
  3. Test Utilities - src/test/utils/screen-test-utils.tsx with form interaction helpers
  4. TypeScript Config - Updated to include test files and path aliases

🧪 Testing

# Run all tests
npm test

# Run login-id tests only
npm test -- --testPathPatterns="login-id"
Screenshot 2025-07-13 at 10 46 13 PM

📈 Scaling to Other Screens

This setup works for login-id screen. For other screens, you'd need to:

  1. Create separate mock files for each screen (signup.ts, password-reset.ts, etc.)
  2. Each mock needs screen-specific data structure
  3. Test utilities should work across screens since they find elements by accessible labels

Whether this scales well to 80+ screens depends on how similar the screen structures are. If screens have very different data formats or UI patterns, the utilities might need modification.

▶️ Flow

graph TD
    A[Test _test_ File] --> B[Import SDK]
    B --> C[Jest  _mocks_  Directory]
    C --> D[Screen-Specific Mock Data]
    D --> E[Test Utilities Help Interaction]
    E --> F[Test Assertions]
    
    subgraph "Mock Structure"
        G[__mocks__/login-id.ts]
        H[__mocks__/signup.ts]
        I[__mocks__/password.ts]
        J[... other screens]
    end
    
    C --> G
Loading

This establishes the testing pattern for the login-id screen that can be extended to other screens.

Copy link
Contributor

@grandmaester grandmaester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amberkamboj77 Looks good. Added few minor comments. Please check

grandmaester
grandmaester previously approved these changes Jul 10, 2025
Copy link
Contributor

@grandmaester grandmaester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Copy link
Contributor

@HVish HVish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@amberkamboj77 amberkamboj77 merged commit d64c0f9 into main Jul 14, 2025
2 checks passed
@amberkamboj77 amberkamboj77 deleted the feat/jest-setup branch July 14, 2025 07:32
grandmaester pushed a commit that referenced this pull request Jul 15, 2025
* feat: jest setup and test cases for login-id screen

* fix: package.lock

* fix: socialLogin to federatedLogin

* fix: test case and readme addition

* fix: test cases refactoring, readme update

* refactoring(testing): improve jest setup, include ts support better, upgrade components for better testability, mocks improvements

* fix: package-lock upgrade, verbatimModuleSyntax disabled for uds
amberkamboj77 pushed a commit that referenced this pull request Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants