Skip to content

Testing

dweller long gone edited this page May 28, 2026 · 6 revisions

Testing

ASN.1 Instance Builder uses TypeScript checks, Vitest tests, and the production build to protect the parser, Schema Model, diagnostics, DER builder, browser application wiring, package entry points, and generated declaration files.

Run the standard checks from the main repository:

npm run check
npm test
npm run build

For package or release-related changes, also run:

npm run pack:dry-run

What npm run check Covers

npm run check runs:

tsc --noEmit

This verifies the TypeScript project without writing build output.

The check protects exported TypeScript contracts for:

  • Core API exports from @pkistudio/asn1instancebuilder and @pkistudio/asn1instancebuilder/core.
  • initAsn1InstanceBuilder from @pkistudio/asn1instancebuilder/app.
  • Schema Model types such as Asn1SchemaModule, Asn1Type, Asn1Field, and InstanceDocument.
  • Diagnostics types such as SchemaDiagnostic and InstanceDiagnostic.
  • Local PkiStudioJS type definitions.

What npm test Covers

npm test runs the Vitest suite.

Current tests cover areas such as:

  • ASN.1 definition parsing.
  • Module headers and tag defaults.
  • Explicit, implicit, and automatic tagging behavior.
  • Named integer values.
  • Negative INTEGER DER encoding.
  • Binary input forms and validation.
  • Defaults and ENUMERATED behavior.
  • OID names.
  • Schema diagnostics.
  • Instance diagnostics.
  • PKI component fixtures.
  • Minimal TBSCertificate, Certificate, CertificateList, and CertificationRequest fixtures.

What npm run build Covers

npm run build runs:

npm run build:types && npm run build:lib && npm run build:app

This verifies generated declaration files, library output, browser app output, and standalone viewer output.

The production build covers:

  • index.html and the browser application shell.
  • viewer.html and standalone PkiStudioJS viewer routing.
  • dist/index.js.
  • dist/core.js.
  • dist/app.js.
  • dist/asn1instancebuilder.css.
  • Type declarations under dist/types.

What the Standard Checks Do Not Cover

The standard checks do not replace full browser verification.

They do not currently cover:

  • Full browser UI interaction flows.
  • Visual regression checks.
  • Clipboard permission behavior across browsers.
  • Native download behavior across browsers.
  • Popup blocker behavior for standalone PkiStudioJS viewer windows.
  • Splitter persistence and layout behavior across viewport sizes.
  • Large real-world ASN.1 module corpora.
  • Full X.509, CSR, and CRL production-grade profile validation.

Use browser verification when changing menus, clipboard/file flows, definition loading, sample selection, diagnostics rendering, DER build flow, viewer-window routing, API Log behavior, or splitters.

Suggested Browser Smoke Checks

For user-facing application changes, verify the relevant parts of this list:

  • Start the app with npm run dev -- --port 5173 --strictPort.
  • Load Person from Load -> NamedObjects, build DER, and confirm PkiStudioJS opens.
  • Load fixtures/person.definition-bundle.json from Load -> Definition Bundle, confirm Person is selected with sample input, and build DER.
  • Load an invalid Definition Bundle JSON file and confirm Definition Bundle diagnostics appear in the Diagnostics pane and API Log.
  • Save the active workspace from Save -> Definition Bundle and confirm the exported JSON includes schema source, selected type, and sample input.
  • Switch between Form and JSON, edit a value in Form mode, and confirm the JSON view reflects the same instance value.
  • Enter invalid JSON, switch to Form, and confirm the Form view reports the parse error without losing JSON editing access.
  • Load Certificate, select child types from the Instance Input type selector, and confirm sample input changes when available.
  • For Certificate, CertificationRequest, CertificateList, and PkiBundle, switch to Form and confirm representative UI Profile metadata is visible, such as signature labels, PKI section ordering, and collapsed issuer, subject, public key, extension, attribute, or revoked certificate groups.
  • Load a local .asn1 fixture from fixtures/.
  • Load definition text from the clipboard.
  • Save the active definition to a file.
  • Trigger a schema diagnostic and confirm DER generation is blocked.
  • Trigger an instance diagnostic and confirm DER generation is blocked.
  • Confirm API Log entries appear for parse, diagnostics, build, viewer opening, and generated DER parsing.
  • Confirm pane resizing persists after reload.

In VS Code, the Start asn1instancebuilder server task starts the development server on port 5173.

Clone this wiki locally