Testing Strategies

The project utilizes Jest and Enzyme to achieve comprehensive testing coverage, encompassing both unit and integration tests.

Jest:

  • A JavaScript testing framework popular for its speed and rich features.
  • Provides a clear and concise syntax for writing assertions and expectations.
  • Enables mocking and stubbing of dependencies to isolate units of code.

Enzyme:

  • A JavaScript testing utility for React.
  • Simplifies the process of traversing and manipulating React components for testing purposes.
  • Offers a suite of methods for simulating user interactions and asserting on component state.

Example Tests:

  • presenter-app/tests/controllers/GameController.test.tsx: Contains numerous tests for the GameController class. These tests cover various scenarios for calculating prizes won based on player performance in the game.

Test Runner:

  • The npm run test command executes Jest and Enzyme tests, providing a comprehensive assessment of the project’s codebase.
  • enzyme-adapter-preact-pure is specifically employed for testing Preact components, ensuring compatibility with the project’s UI framework.

Setup:

  • The presenter-app/tests/__mocks__/setupTests.ts file configures Enzyme with the appropriate adapter for Preact.

Additional Notes:

  • The QuestionController class, located in presenter-app/src/controllers/QuestionController.ts, includes checks to prevent duplicate questions and ensure answer integrity. These checks play a vital role in maintaining the consistency and reliability of the game.

Documentation References:


          ## Top-Level Directory Explanations
          
          <a class='local-link directory-link' data-ref="audience-app/" href="#audience-app/">audience-app/</a> - This directory contains the files for the audience-facing part of the application. It includes HTML files for different pages, static assets like images, and configuration files for Firebase and npm.
          
          <a class='local-link directory-link' data-ref="audience-app/public/" href="#audience-app/public/">audience-app/public/</a> - This subdirectory holds the publicly accessible files of the audience app. It includes HTML files for specific pages, images, and other static assets.
          
          <a class='local-link directory-link' data-ref="presenter-app/" href="#presenter-app/">presenter-app/</a> - This directory contains the files for the presenter-facing part of the application. It includes source code, static assets, and configuration files.
          
          <a class='local-link directory-link' data-ref="presenter-app/build/" href="#presenter-app/build/">presenter-app/build/</a> - This subdirectory holds the compiled and bundled files for the presenter app. It includes HTML, CSS, JavaScript, and image files.
          
          <a class='local-link directory-link' data-ref="presenter-app/src/" href="#presenter-app/src/">presenter-app/src/</a> - This subdirectory contains the source code for the presenter app. It includes components, controllers, routes, styles, and utility functions.
          
          <a class='local-link directory-link' data-ref="presenter-app/tests/" href="#presenter-app/tests/">presenter-app/tests/</a> - This subdirectory contains test files for the presenter app. It includes mocks, controllers, and declarations.