Hasty Briefsbeta

Testing a compiler-driven full-stack web framework

8 hours ago
  • #web-framework
  • #testing
  • #compiler
  • Wasp is a compiler-driven full-stack web framework generating complete source code for web apps.
  • Testing in Wasp involves a large surface area due to its unique design, requiring strong automated tests.
  • Test code is treated with the same care as production code to avoid slowing down development.
  • Tests are designed to be readable at a glance, with clear input and expected output.
  • Haskell's DSL capabilities enhance test readability, though Unicode operators can be tricky.
  • Wasp avoids chasing 100% test coverage, focusing instead on meaningful test cases that catch important errors.
  • Type-Driven Development is preferred over Test-Driven Development, leveraging strong typing in TypeScript and Haskell.
  • The compiler, written in Haskell, is tested with unit tests and end-to-end (e2e) tests for generated code.
  • Snapshot tests track changes in generated code, comparing current output with expected (golden) snapshots.
  • Mustache templates for code generation are being migrated to npm packages for better TypeScript tooling.
  • Wasp apps, including starter templates and example apps, are tested in runtime using Playwright e2e tests.
  • The 'kitchen-sink' app tests most framework features, with additional apps covering mutually exclusive features.
  • A 'wasp-app-runner' tool simplifies test automation for Wasp apps, supporting both dev and build commands.
  • Deployment is tested by automatically deploying the 'kitchen-sink' app and running smoke tests.
  • Documentation examples are linked to source code in example apps to prevent stale examples.
  • A Docusaurus plugin, 'code-ref-checker', ensures docs' code examples match the source code.
  • Tutorials are made testable with TACTE (Tutorial Action Executor), automating step execution and validation.