For the complete documentation index, see llms.txt. This page is also available as Markdown.

Testing and Quality Assurance

This tutorial will guide you through testing and quality assurance practices in the OADA UI project. You'll learn how to implement unit tests, integration tests, and best practices for testing.

Testing Setup

1. Testing Configuration

The project uses Create React App (CRA) with CRACO for configuration. The testing setup is configured in package.json. The following script commands are used to run different testing scenarios:

{
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "react-scripts eject",
    "analyze": "npm run build"
  }
}

2. Test Utilities

The project uses React Testing Library for component testing. The setup file extends Jest's expect functionality with additional DOM-specific matchers. This allows us to use assertions like toBeInTheDocument() and toHaveClass() in our tests:

// src/setupTests.ts
import "@testing-library/jest-dom/extend-expect";

Unit Testing

1. Component Testing

The FAQ component demonstrates how to test both static content and dynamic data rendering. The test suite includes:

  • Verifying the presence of static text elements

  • Checking the rendering of dynamic FAQ content

  • Using test IDs for reliable element selection

  • Testing component structure with nested elements

2. App Component Testing

The main App component test demonstrates how to:

  • Set up the Redux store provider

  • Test the basic rendering of the application

  • Use regular expressions for flexible text matching

  • Test components within the Redux context

Integration Testing

1. Blockchain Provider Testing

The blockchain provider tests demonstrate how to:

  • Test asynchronous blockchain operations

  • Mock external blockchain endpoints

  • Verify protocol parameter fetching

  • Test UTxO (Unspent Transaction Output) handling

  • Ensure proper delegation to the Blockfrost service

2. Redux Store Testing

The Redux store configuration shows how to:

  • Set up multiple reducers for different features

  • Configure middleware with custom services

  • Handle asynchronous actions with thunk middleware

  • Manage application state for wallet, OADA actions, and alerts

Best Practices

  1. Component Testing

    • Test component rendering

    • Test user interactions

    • Test state changes

    • Test edge cases

  2. Integration Testing

    • Test blockchain interactions

    • Test Redux store integration

    • Test service layer

    • Test error handling

  3. Testing Guidelines

    • Use React Testing Library for component tests

    • Mock external dependencies

    • Test both success and error cases

    • Follow the testing pyramid principle

Next Steps

Now that you understand testing and quality assurance, you can proceed to:

  1. Deployment and CI/CD

  2. Contributing to the Project

Additional Resources

Last updated