A guide to unit testing 11ty static site templates written in TypeScript/JavaScript using Vitest. The approach leverages 11ty's JavaScript template language, where templates are defined as classes with data and render methods. Tests use JavaScript's apply method to swap out the this context, enabling stubbing of template dependencies and testing different data scenarios without running the full 11ty build.
3 Impressions