This directory contains unit and integration tests for the LightScripts framework. The tests are written using Vitest, a Vite-native testing framework.
controls.test.ts- Tests for the control utilities moduledebug.test.ts- Tests for the debug logging moduleparser.test.ts- Tests for the HTML template parsereffect.test.ts- Tests for the BaseEffect classengine.test.ts- Tests for the DevEnginebuild.test.ts- Tests for the build process and effects configuration
You can run the tests using the following npm scripts:
# Run all tests once
npm test
# Run tests in watch mode (automatically rerun on file changes)
npm run test:watch
# Run tests with coverage report
npm run test:coverageWe aim to maintain high test coverage for the framework code. The coverage report will show which parts of the code are covered by tests. The report is generated in the coverage directory when running the test:coverage script.
When adding new features to the framework:
- Add corresponding test files in this directory
- Follow the naming convention:
<module-name>.test.ts - Use the existing tests as a reference for structure and style
- Make sure to test both success and error conditions
Many tests use mocks to isolate the component being tested:
- THREE.js is mocked to avoid creating actual WebGL contexts in tests
- DOM APIs like
documentandwindoware mocked when needed - The file system (fs) is mocked for build process tests
These tests run automatically in CI when changes are pushed to the repository. All tests must pass before the pull request can be merged.