How kolodny/safetest works
Main System Components
• Core Testing Library: This is the nucleus where the core test lifecycle is managed (e.g., in the “src” folder: modules like setup.ts, render.ts, bootstrap.ts, expect.ts, etc.). This part orchestrates test execution and communication between Node and browser.
• Test Runner Adapters: Separate implementations for different test runners (see “safetest/jest” and integrations for Vitest in config files and examples). These wrap the testing API to allow familiar syntax and integration.
• Browser Automation Layer: The integration with Playwright (and its configuration) which is used to drive real browser instances and record artifacts such as screenshots, videos, and traces.
• Framework Adapters: These include modules for React, Vue, Svelte, Angular, and Solid (for example, files in “src/react.ts”, “src/vue.ts”, etc.) that bootstrap and render components, and allow the tests to be written in a framework-specific manner.
• Override/Mimic and Bridge Mechanism: Components that provide test-time overrides (see usage of “createOverride”) and enable two-way communication between the Node environment and the in-page browser context. This mechanism lets you intercept test execution to simulate errors or change props.
• Artifacts and Reporting Module: The system that collects test outcomes, snapshots (via jest-image-snapshot), trace files, and videos; then processes them for a unified report (as seen in the reporting section of the README and the use of “safetest/report”).
• CLI and Environment Configuration: The support for environment variables (like OPT_URL, OPT_DOCKER, OPT_CI), along with the scripts in package.json, providing ways to run in local or CI modes (including Docker integration for deterministic snapshots).
Project’s File Structure for Architectural Clues
• The top-level directories include examples (a variety of front-end project samples for Angular, Create React App, Next.js, various Vite configurations, etc.) which point to how Safetest is intended to be used in multiple front-end frameworks.
• The “src” folder contains core modules that underlie the testing library functionality (rendering, bootstrapping, test hooks, browser-mock setup, snapshot helpers, etc.).
• The project also contains various configuration files (like tsconfig.json, .npmignore, .gitignore, build scripts, and GitHub workflows) that help with testing, reporting, and automation on CI/CD pipelines.