Testing
Testing
Tests use the Node built-in runner (node:test and node:assert/strict), run through tsx.
npm run typecheck # source, DOM-harness tests, and Cloudflare worker examplenpm test # parser suite + semantic diff / render / CLI + CI reporter coveragenpm run test:parser # parser regression suite onlynpm run test:org # offline Salesforce org-mode runner, picker, and error coveragenpm run typecheck runs the TypeScript compiler on three projects:
tsconfig.jsonchecks source and scripts, without browser globals.tsconfig.test.jsonchecks the tests. Its harness imports happy-dom’s types.tsconfig.worker.jsonchecks the Cloudflare worker example with its worker types.
The exit code is the gate. It runs before build and tests in prepublishOnly, and as a step in repository CI.
Layout
test/parser.test.ts: the vendored parser’s own suite, ported tonode:test. It shows the Apache-2.0 parser behaves the same under Node. See vendoring.md.test/org-flow.test.ts: offline org-mode coverage. Tooling version parsing, exact retrieve-path resolution, token-leak protection, picker formatting and defaults, dispatch, error mapping, and non-TTY behavior.test/org-sfd.test.ts: offline coverage of thesfdpath and thesf/sfdchoice.FLOW_DELTA_SF_CLIparsing, sfd query and retrieve parity withsf, auto fallback and forced-sfderrors,sf-only mode, debug fallback reasons, and discarding partial sfd retrieves before thesfretry.test/semantic-diff.test.ts: the core of FlowDelta. Canonicalization, flow-header extraction,deepDiffpaths, node/edge/header classification, edge-id rules, the HTML render, the CLI in file, git, org, and as-built snapshot modes, and the real before/after fixture assertions.test/metadata-io.test.ts: the shared metadata and Git IO contract. Literal and supported glob matching, separator normalization, union and changed-only discovery, deterministic paths, and Git error handling.test/report-core.test.ts: the reporting core shared by both products and both CI platforms (buildComment, the vocabulary-driven builder,isZeroSummary,findStickyNote). Also the package, bin, and build smoke checks for all six published binaries.test/gitlab-report.test.ts: GitLab reporting. The artifact-URL scheme and the sticky-noteupsertCommentbehavior (list, then PUT or POST).test/github-report.test.ts: GitHub reporting. The artifact-URL scheme, the issue-commentsupsertCommentbehavior (list, then PATCH or POST, no/usercall), andmain()orchestration (PR-number resolution fromGITHUB_EVENT_PATHor--pr, no-op paths, attribute-only diffs). See ci.md for the reporting flows themselves.test/compact-format.test.ts: the--format md|jsonoutput for comparisons and as-built snapshots, including the stdout-only contract, theflow-delta/compact@1schema, and the as-built--file,--org, and--repoforms throughmain().test/outline.test.ts: the as-built execution outline (--as-built --format md). It compares goldens intest/goldens/outline/and checks decisions, loops, fault paths, cycles, missing starts, and unreachable elements.test/cli-flags.test.ts: the--versionand unknown-option behavior of all six published binaries. Each prints<bin> <package version>and creates no output directory, and unknown options don’t throw. See cli.md.test/smoke-common.test.ts: the shared smoke-harness helpers used by both the GitLab and GitHub smoke scripts (for examplerenameFlowMetadataandstageAndCommit).test/smoke-github.test.ts: the GitHub smoke entrypoint and generated workflow, including both Flow and FlexiPage diff and report pipelines.docs-site/test/docs-site.test.mjs: the documentation site’s own suite, run bynpm testindocs-site/(and by itsnpm run build). It coversllms.txt, README as the site index, rewritten links, and pinned source URLs. See docs-site.md.
Rendered-artifact DOM harness
test/dom-harness.ts is the default way to test generated client behavior. renderDom(html, storage?) does the following:
- Parses a complete rendered Flow or FlexiPage artifact with
happy-dom. - Enables inline JavaScript.
- Seeds
localStoragebefore the document is parsed. - Waits for the document to settle.
- Returns the live
windowanddocument.
Both renderer suites assert the shared shell contract: four filters, three theme choices, panel controls, offline output, and theme-key continuity. They also assert product-specific behavior. Tests should interact with the returned DOM and storage. Don’t extract or match the generated script text.
The harness is test-only. happy-dom is a development dependency, and rendered artifacts stay self-contained and offline. Script errors at load time fail renderDom. Its errors collection also exposes errors raised by later interactions, so tests can assert the client stays clean.
test/semantic-diff.test.ts and test/flexipage-delta.test.ts both use it for filters, theme and view persistence, detail-panel selection, keyboard activation, and stored or invalid preference handling.
The pointer-driven panel resizer is deliberately not covered. It depends on layout geometry that happy-dom doesn’t compute, so check it visually.
Fixtures (fixtures/)
fixtures/parse/*.flow-meta.xml: single-flow goldens for parser coverage.fixtures/diff/<case>/before.flow-meta.xmlandafter.flow-meta.xml: real before/after pairs retrieved from an org, one directory per scenario. The scenarios arenoop_save,add_node,modify_assignment,modify_decision,rewire_connector, andfault_path. The header-only cases aredeactivate_flowandbump_api_version.
Two fixtures matter most:
noop_saveis a real save with only coordinate churn. It must produce zero node and edge changes. This is the main canonicalization gate.deactivate_flowis the main flow-level fixture. The graph is unchanged, butstatusmoves fromActivetoDraftandsummary.changedFlowAttributesis 1.
npm run render:fixtures -- flow also renders each fixture’s after file as an as-built snapshot. It’s named <fixture>.snapshot.html, with its optional JSON beside it.
FlexiPage fixtures
FlexiPage pairs live under fixtures/flexipage-diff/<case>/:
noop_save: Facet GUID regeneration, property reordering, and region-block reordering. The semantic summary must be all zero.insert_component_top: LCS insertion with no modification cascade.change_template: a page-attribute-only change with a reporter callout.add_component: a component addition.modify_component_property: a generic property delta.
The fixtures/flexipage-template/nestedDynamicForms/ pair covers:
- transitive tab, accordion, field-section, and column nesting;
- regenerated Facet GUIDs;
- the former collision-loser
+2/−2/~1add/remove scenario; and - a field added with a visibility rule.
The focused suite also locks down:
- duplicate field identity;
- name-keyed multi-property diffs;
- criterion-level visibility changes;
- breadcrumb placement;
- wireframe rollup counts;
- direct region-plus-nested aggregation;
- multi-container digest grouping;
- pill-versus-row click isolation; and
- digest drill-down and back navigation.
test/flexipage-delta.test.ts walks these on-disk pairs. It also covers:
- reorder as delete plus add;
- region additions, removals, and mode changes;
- whole-page add and delete;
- parser shape coverage;
- orphan GUID facets;
- outline rendering;
- CLI file mode; and
- CLI git mode against two temporary commits.
Adding a diff fixture
- Retrieve the flow and commit it. Make the change in the org and retrieve again. The two versions are your
beforeandafter. Keep the internal flow<label>andfullNamethe same in both files, so artifact names aren’t confusing. - Put them under
fixtures/diff/<your_case>/. - Add a row to the
DIFF_CASEStable intest/semantic-diff.test.tswith the expected summary counts. Optionally add a targeted assertion on the changed property path or edge. - Run
npm test, and check the render withnpm run render:fixtures -- flow.
Take the expected counts from the validated CLI output (the --json summary). Don’t guess them.
Manual and visual smoke
The automated org-mode suites are offline. For a live smoke, use an authenticated scratch org with a Flow that has at least two versions. Time the same command with FLOW_DELTA_SF_CLI set to sf, sfd, and auto. Warm the daemon before the sfd and auto runs and compare stdout and stderr byte for byte.
flow-delta --org <alias> --flow <Name> --from-version <n> --to-version <n> --format jsonUse a separate SFD_RUNTIME_DIR for the smoke so sfd stop only stops the test daemon. Run auto again after stopping it to check cold startup. Because sfd can restart itself, also point SFD_RUNTIME_DIR at a regular file to make startup fail. Verify that auto still matches the sf output. With FLOW_DELTA_DEBUG=1, stderr should report one fallback for the query and one for retrieval. Record parity, timings, and fallback results in the PR. To check artifact generation, run with --out and open the artifacts in the reported directory.
npm run render:fixtures -- flow writes Flow artifacts to flow-delta-out/fixtures/. npm run render:fixtures -- flexipage writes FlexiPage artifacts to flexipage-delta-out/fixtures/. With no argument, it renders both. Open the artifacts and check:
- Status colors (added, deleted, modified, unchanged) and the legend.
- The four view filters (All, After, Before, Changes only).
- Edge arrowheads: solid for normal edges, dashed for fault edges.
- The side panel and its semantic organization:
- Type-specific nodes (decision, assignment, record*, and so on) group changes into named sections such as “Outcomes” and “Field Mappings”. Click a complex modified node to see structured tables with columns.
- Added and deleted nodes show empty-state messages.
- Simple scalar changes fall back to a “Configuration” section.
- Pan and zoom on the canvas.
- Resizing the side panel by dragging its left edge.
- Collapsing and reopening the panel with the toggle button.
- Flow-level banners for
deactivate_flowandbump_api_version. The graph should stay unchanged while the banner reports the root-attribute changes.
For snapshot artifacts (<fixture>.snapshot.html), check the type-color legend, the element inventory, the absence of diff filters, neutral one-sided properties, flow facts, and the provenance footer.
On rewire_connector, check that After and Before each render as a coherent single-state graph. A fuller manual checklist and the fixture scenario matrix are in this file and in the inline comments in test/semantic-diff.test.ts.
For FlexiPage fixtures, the automated checks are the main gate. Manual review is optional. If you do it, use npm run render:fixtures -- flexipage and inspect:
- the nested region and Facet outline;
- status filters;
- the template callout;
- wireframe change-count pills;
- grouped digest headings;
- digest drill-down and back behavior; and
- the detail panel.
See flexipage.md for the as-built artifact behavior and known boundaries.