This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snapshot tests to catch regressions not covered in tests
This commit has been cherry picked from its original appearance in #164, with the following changes: - Include all enketo-core fixtures in preparation for adding benchmarks to establish a performance baseline. - Temporarily increase the timeout for snapshot tests so that the longer running enketo-core fixtures can generate initial snapshots. - Restore test shuffling (turning that off was a mistake in the original TypeScript PR). - Switch the default test reporter to `dot` to improve visibility of progress during test runs (it's still not great, mainly due to performance). - Move `linkedom` stuff to `/test/shared.ts` as it will only be used in tests. - Accept updates to `package-lock.json` with SHA-512 integrity hashes. - Excludes formatting of XML/XSL. About snapshot serialization: Snapshots use a custom serializer designed to identify only meaningful differences. This means that a snapshot matches if: - the value is exactly equal - the value is equal, apart from insignificant changes to whitespace and/or attribute order The serialization logic: 1. Manually ensures consistent attribute order (using `linkedom` as a DOM compatibility library, primarily because its types are much better than those for `@xmldom/xmldom`). 2. Uses `prettier` to normalize whitespace. 3. Uses `pretty-format` (`vitest`'s default) for final serialization. Apart from adding snapshots, tests have been updated to reference `linkedom`'s types (corrected where necessary) and to its behavior (which is semantically equivalent to the previous `@xmldom/xmldom` usage, but more consistent with a real DOM environment).
- Loading branch information