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

@gravitate-health/lens-tool-test

v1.0.3

Published

Testing toolkit for Gravitate Health lens development with bundled test data

Readme

Gravitate Health Lens Testing Toolkit

A comprehensive testing toolkit for Gravitate Health lens development. This library provides utilities for testing lenses with bundled test data (ePIs and IPS) and allows developers to extend the test data with their own resources.

Features

  • 🧪 Bundled Test Data: Includes 7 preprocessed ePIs and 2 IPS resources for immediate testing
  • 🔧 Extensible: Add your own test data alongside bundled resources
  • Comprehensive Utilities: Helper functions for loading, applying, and validating lenses
  • 📊 Content Validation: Automated checks for content preservation and lens behavior
  • 💡 TypeScript Support: Full type definitions included

Installation

npm install @gravitate-health/lens-tool-test

Peer Dependencies

npm install @gravitate-health/lens-execution-environment

Quick Start

Basic Usage

import {
  loadEPI,
  loadIPS,
  loadLens,
  applyLens,
  hasFocusingErrors,
  isContentPreserved
} from '@gravitate-health/lens-toolkit-test';

// Load test data from bundled resources
const epi = loadEPI('Bundle-processedbundledovato-en.json');
const ips = loadIPS('alicia-patient_summary.json');

// Load and compile your lens
const myLens = loadLens('./lenses', 'my-lens');

// Apply the lens
const result = await applyLens(epi, ips, myLens);

// Validate the results
if (hasFocusingErrors(result)) {
  console.error('Lens has errors!');
}

if (!isContentPreserved(epi, result.epi)) {
  console.error('Content was removed!');
}

Writing Tests

import {
  loadAllEPIs,
  loadAllIPS,
  loadLens,
  applyLens,
  hasFocusingErrors,
  isContentPreserved,
  isTextHighlighted
} from '@gravitate-health/lens-toolkit-test';

describe('My Lens Tests', () => {
  const myLens = loadLens('./lenses', 'my-lens');
  
  test('should highlight pregnancy warnings', async () => {
    const epi = loadEPI('Bundle-processedbundledovato-en.json');
    const ips = loadIPS('alicia-patient_summary.json');
    
    const result = await applyLens(epi, ips, myLens);
    
    expect(hasFocusingErrors(result)).toBe(false);
    expect(isTextHighlighted(result.epi, 'pregnancy')).toBe(true);
    expect(isContentPreserved(epi, result.epi)).toBe(true);
  });
});

Extending Test Data

Add your own test data alongside the bundled resources:

import { configureTestData, loadAllEPIs } from '@gravitate-health/lens-tool-test';

// Configure custom paths
configureTestData({
  pepisPath: './my-test-data/pepis',
  ipsPath: './my-test-data/ips'
});

// loadAllEPIs() now includes both bundled and custom ePIs
const allEPIs = loadAllEPIs();

API Reference

Data Loading

  • loadEPI(filename) - Load specific ePI by filename
  • loadAllEPIs() - Load all ePIs (bundled + custom)
  • loadIPS(filename) - Load specific IPS by filename
  • loadAllIPS() - Load all IPS resources (bundled + custom)
  • configureTestData(paths) - Configure custom test data paths
  • resetTestDataConfig() - Reset to bundled data only

Lens Operations

  • loadLens(dir, baseName) - Load and compile a lens
  • applyLens(epi, ips, lens) - Apply single lens
  • applyMultipleLenses(epi, ips, lenses) - Apply multiple lenses

HTML Analysis

  • extractHTMLFromEPI(bundle) - Extract HTML sections
  • extractTextContent(html) - Strip HTML tags
  • isTextHighlighted(epi, text, options?) - Check if text is highlighted
  • isTextCollapsed(epi, text, options?) - Check if text is collapsed
  • countElementsWithClass(epi, className) - Count elements with CSS class

Validation

  • hasFocusingErrors(result) - Check for errors
  • getFocusingErrors(result) - Get error messages
  • isContentPreserved(original, enhanced, threshold?) - Verify content preservation
  • getContentPreservationMetrics(original, enhanced) - Get detailed metrics

Project Structure

lens-tool-test/
├── src/                     # Source code
│   ├── index.ts            # Main exports
│   ├── types.ts            # TypeScript definitions
│   ├── data-loader.ts      # Test data loading
│   ├── lens-utils.ts       # Lens operations
│   ├── html-utils.ts       # HTML analysis
│   └── validation-utils.ts # Validation functions
├── data/                    # Bundled test data
│   ├── PePIs/              # 7 preprocessed ePIs
│   └── IPS/                # 2 IPS resources
├── dist/                    # Compiled output (published)
└── package.json

Building from Source

# Install dependencies
npm install

# Build (compiles TypeScript and copies data)
npm run build

# Run tests
npm test

License

MIT

Contributing

Contributions welcome! Please ensure:

  • All tests pass
  • TypeScript best practices followed
  • New features include tests and documentation

Support

For issues, please open a GitHub issue.