Test Generation
Generate tests for the unicornstudio-react library.
Setup (if no test framework is configured)
If no test config exists yet:
- Recommend installing vitest + @testing-library/react + jsdom
- Create a vitest.config.ts at the project root
- Add a
testscript to package.json
Generating Tests
When the user specifies a file or module to test:
- Read the source file to understand its exports, props, and behavior
- Generate a test file in a
__tests__/directory adjacent to the source, named<module>.test.tsxor<module>.test.ts - Cover:
- Default behavior and rendering
- Props variations
- Edge cases (missing props, invalid values)
- Hook behavior (state changes, cleanup, side effects)
- WebGL detection fallback paths
Conventions
- Use
describe/itblocks - Mock external dependencies (UnicornStudio SDK, next/script, next/image)
- Test both React and Next.js variants when applicable
- Verify cleanup functions are called on unmount
Source: diegopeixoto/unicornstudio-react — distributed by TomeVault.