npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@judo/testing

v0.1.1

Published

Shared test utilities and fixtures for JUDO UI Runtime

Downloads

158

Readme

@judo/testing

Shared test utilities and fixtures for JUDO UI Runtime

Purpose

Test infrastructure for the entire monorepo. Loads and caches real example .model files, creates factory objects for data-layer types, resolves actions via ModelRegistry, and offers tree-traversal/assertion helpers for the visual element hierarchy. No React hooks or context providers — this is a pure Node.js/Vitest utility library.

Architecture Layer

Layer 2 (Cross-cutting) — consumed by test suites across all packages.

Dependencies

  • @judo/model-api — type definitions
  • @judo/model-loader — model loading and registry
  • @judo/model-parser — XML parsing

File Structure

src/
├── index.ts                # Barrel re-exports
├── model-loader.ts         # Loads & caches example .model files
├── model-fixtures.ts       # Lazy-getter objects for every example model
├── factories.ts            # Factory functions for data-layer types
├── mock-services.ts        # Action factory helper
├── action-fixtures.ts      # Action resolution & lookup helpers
├── visual-tree.ts          # Visual element tree traversal & assertions
└── *.test.ts               # Tests for each module

Exports Summary

Model Loading

| Export | Kind | Description | | --------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- | | ExampleModelName | type | Union of 8 available example model names: "SimpleOrderManagement", "DebateTest", "CRUDActionsTest", etc. | | loadExampleModel(name) | function | Reads an example .model XML file, parses it, resolves all references, and caches the result. Returns Application[]. | | loadExampleApp(name) | function | Returns the first Application from a model (for single-actor models). | | loadExampleAppByActor(modelName, actorName) | function | Returns the Application whose name matches. Throws with available names on miss. | | clearModelCache() | function | Clears the internal model parse cache for test isolation. | | getAvailableModelNames() | function | Returns the list of all 8 ExampleModelName values. |

Model Fixtures

| Export | Kind | Description | | ---------------- | -------- | ------------------------------------------------------------------------------------ | | EXAMPLE_MODELS | constant | Object with lazy getters — provides Application[] for every example model. | | EXAMPLE_APPS | constant | Object with lazy getters — provides the first Application for every example model. |

Action Fixtures

| Export | Kind | Description | | -------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ResolvedAction | interface | A fully-resolved action with xmi:id, name, actionDefinition: ActionDefinition, and optional targetPageDefinition, targetDataElement, ownerDataElement. | | getModelRegistry(modelName) | function | Returns (or creates & caches) a ModelRegistry populated with all applications from an example model. | | resolveAction(modelAction, registry) | function | Converts a model Action to a ResolvedAction. Returns undefined if unresolvable. | | findActionsByType(app, actionType, registry) | function | Collects all ResolvedActions from every page whose actionDefinition.@type matches. | | findFirstActionByType(app, actionType, registry) | function | Returns the first matching resolved action across all pages, or undefined. | | getPageActions(page, registry) | function | Returns all resolved actions from a single page definition. | | getCRUDTestAction(actionType) | function | Shortcut — loads CRUDActionsTest model and finds first action matching the given type. | | getActionGroupTestAction(actionType) | function | Shortcut — loads ActionGroupTest model and finds first action matching the given type. | | clearRegistryCache() | function | Clears the internal registry cache for test isolation. |

Visual Tree Utilities

| Export | Kind | Description | | ------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ | | VisualTreeExpectation | interface | Declarative shape for tree assertions: type (required), optional name, sourceId, and recursive children. | | AssertionResult | interface | Result of a tree assertion: passed flag, optional message and path. | | assertVisualTreeResult(actual, expected, path?) | function | Recursively compares a VisualElement tree against expected shape. Returns a detailed AssertionResult (non-throwing). | | assertVisualTree(actual, expected) | function | Throws if the tree doesn't match. Wrapper around assertVisualTreeResult. | | getChildren(element) | function | Extracts child VisualElements from any container. | | findVisualElementByType(root, type) | function | Depth-first search by @type. | | findAllVisualElementsByType(root, type) | function | Collects all elements matching a type (depth-first). | | countVisualElementsByType(root, type) | function | Counts elements of a given type. | | findVisualElementByName(root, name) | function | Depth-first search by name. | | findVisualElementBySourceId(root, sourceId) | function | Depth-first search by sourceId. | | getTreeDepth(element) | function | Returns maximum depth of the visual tree (1-based). | | flattenVisualTree(element) | function | Depth-first flattening into a flat array. |

Data Factories

| Export | Kind | Description | | ----------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------- | | TestClassTypeOptions | interface | Options for createTestClassType. | | createTestClassType(options?) | function | Factory for ClassType with sensible defaults. Auto-generates unique xmi:id. Sets @type to "data:ClassType". | | TestRelationTypeOptions | interface | Options for createTestRelationType. | | createTestRelationType(options?) | function | Factory for RelationType. Defaults: isCollection: true, isOptional: false, relationKind: "ASSOCIATION", memberType: "MAPPED". | | TestAttributeTypeOptions | interface | Options for createTestAttributeType. | | createTestAttributeType(options?) | function | Factory for AttributeType. Defaults: memberType: "MAPPED", isReadOnly: false, isFilterable: true. | | TestDataTypeOptions | interface | Options shared by all DataType factories. | | createTestStringType(options?) | function | Factory for a StringType DataType. Sets @type to "data:StringType". | | createTestNumericType(options?) | function | Factory for a NumericType DataType. Sets @type to "data:NumericType". | | createTestBooleanType(options?) | function | Factory for a BooleanType DataType. Sets @type to "data:BooleanType". | | createTestDateType(options?) | function | Factory for a DateType DataType. Sets @type to "data:DateType". | | createTestTimestampType(options?) | function | Factory for a TimestampType DataType. Sets @type to "data:TimestampType". |

Mock Services

| Export | Kind | Description | | ------------------------------ | -------- | ----------------------------------------------------------------------- | | createTestAction(overrides?) | function | Factory for an Action object. Defaults to a DeleteActionDefinition. |

Key Patterns

  • Lazy caching: Model parse results and registry instances are cached in Map-based caches. Lazy getter objects defer parsing until first access.
  • Real models, not mocks: All fixtures load actual .model XML files and run them through the full parse → resolve pipeline.
  • Cache-clearing for isolation: clearModelCache() and clearRegistryCache() for resetting shared state between test suites.
  • Factory functions with defaults: Every factory auto-generates a unique xmi:id. All fields have sensible defaults matching EMF defaults.
  • Depth-first tree traversal: All findVisualElement* functions use recursive DFS. getChildren() is the single abstraction for extracting children from containers.
  • Non-throwing + throwing assertion variants: assertVisualTreeResult returns a structured result; assertVisualTree wraps it and throws.