sitez

tests

Sitez's tests that build whole sites. Each source file's unit tests sit beside it in src/.

  • sites/ holds the example sites, one folder each, including the ones that must fail. Each has a vite.config.js, which imports sitez.ts here in place of @amitkaps/sitez/vite.
  • sitez.ts is that import, the plugin from src/, loaded as one copy.
  • build.ts builds one of them through Vite, as vite build would.
  • snapshots/ holds what each site builds to, reviewed as it changes.
  • sites.test.ts builds every site and compares it with its snapshot or its error.txt.
  • browser.test.ts runs the built pages' JavaScript in happy-dom, to show the elements with behavior work.

Folders

  • sites/

    The sites the tests build, one folder each. blog and landing are the first two tests of the idea in design.md. The third, amitkaps.github.io, is ported in its own repo.

Code

  • browser.test.ts

    Built pages loaded into happy-dom with their own scripts. Each element with behavior sets itself up once on the HTML the build wrote, keeps those nodes, and responds to a click. The snapshots show what a page ships, and this shows that it works.

  • build.ts

    What vite build does, from a test: the site's own config file, dist/ somewhere else, and Vite's logger kept in memory. A site that fails rejects with the SiteError the build threw. What the build reports comes back as lines, with Markz's warnings apart from the rest.

  • sites.test.ts

    Every site in tests/sites/ is built. A site builds to the files in tests/snapshots/<site>/ (files.txt lists them, built/ holds the text ones, and warnings.txt has Markz's warnings, when it has any), which are reviewed as they change. An error-… site fails with exactly its error.txt, which is reviewed as a snapshot is. Files are named relative to the site, as vite build prints them from there. Each site is built the way vite build builds it, through its own vite.config.js.

  • sitez.ts

    What each example site's vite.config.js imports in place of @amitkaps/sitez/vite. It is the plugin from src/, and it resolves @amitkaps/sitez, which a site finds in its own node_modules, to src/elementz/index.ts. It follows the plugin's own resolver so that an import browserBoundary should refuse is still refused first.

No prose yet

snapshots/