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 avite.config.js, which importssitez.tshere in place of@amitkaps/sitez/vite.sitez.tsis that import, the plugin fromsrc/, loaded as one copy.build.tsbuilds one of them through Vite, asvite buildwould.snapshots/holds what each site builds to, reviewed as it changes.sites.test.tsbuilds every site and compares it with its snapshot or itserror.txt.browser.test.tsruns the built pages' JavaScript in happy-dom, to show the elements with behavior work.
Folders
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 builddoes, 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 theSiteErrorthe 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 intests/snapshots/<site>/(files.txtlists them,built/holds the text ones, andwarnings.txthas Markz's warnings, when it has any), which are reviewed as they change. Anerror-…site fails with exactly itserror.txt, which is reviewed as a snapshot is. Files are named relative to the site, asvite buildprints them from there. Each site is built the wayvite buildbuilds it, through its ownvite.config.js. - sitez.ts
What each example site's
vite.config.jsimports in place of@amitkaps/sitez/vite. It is the plugin fromsrc/, and it resolves@amitkaps/sitez, which a site finds in its ownnode_modules, tosrc/elementz/index.ts. It follows the plugin's own resolver so that an importbrowserBoundaryshould refuse is still refused first.
No prose yet