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

ai-wallet

v0.0.11

Published

AI Wallet

Downloads

72

Readme

Testing Strategy

This document outlines the testing approach for the AI Wallet component library.

Overview

The testing structure is designed to test the component itself rather than individual examples. This ensures maintainability as the library grows and new framework integrations are added.

Test Structure

tests/
├── component/           # Core web component tests
│   └── ai-wallet.spec.ts      # Thorough component functionality tests
├── react-integration/   # React wrapper tests
│   └── hooks.spec.ts          # React hooks and context tests
└── examples/            # Example app smoke tests
    └── react-app.spec.ts      # Verify React example loads

Testing Approaches

1. Component Tests (tests/component/) - Thorough

Tests the core Stencil web component functionality:

  • Configuration persistence
  • Setup wizard flows
  • Advanced settings
  • Model selection
  • localStorage interactions
  • UI state management

Run these tests:

npm run test:playwright -- --project=component

2. React Integration Tests (tests/react-integration/) - API Testing

Tests the React wrapper functionality:

  • useAIWallet() hook
  • useAIConfig() hook
  • AIWalletProvider context
  • Configuration updates propagation

Prerequisites:

  1. Start the React example: cd examples/react-app && npm run dev
  2. Run tests: npm run test:playwright -- --project=react-integration

3. Example Smoke Tests (tests/examples/) - Light Touch

Simple smoke tests to verify examples load and work:

  • Just verifies the example renders
  • Tests basic integration works
  • One test file per example app

Purpose: Catch if an example is completely broken, but don't test features exhaustively (that's what component tests are for).

Run these tests:

npm run test:playwright -- --project=examples

Running Tests

All Tests

npm run test:playwright

Component Tests Only

npm run test:playwright -- --project=component

React Integration Tests Only

npm run test:playwright -- --project=react-integration

Example Smoke Tests Only

npm run test:playwright -- --project=examples

Interactive UI Mode

npm run test:playwright:ui

Why This Approach?

✅ Benefits

  1. Maintainable: Test the component API, not implementation examples
  2. Scalable: Add Vue, Angular, Svelte examples without new test suites
  3. Fast: Direct component testing is faster than full app testing
  4. Flexible: Easy to add new test scenarios

❌ What We Don't Do

  1. Don't test individual example apps - Examples are documentation, not production code
  2. Don't duplicate tests - One test per feature, not per framework
  3. Don't test through real APIs - Use localStorage mocks and fixtures

Adding New Tests

For New Component Features

Add thorough tests to tests/component/ai-wallet.spec.ts

For New React Features

  1. Update React wrapper in src/react/
  2. Add test to tests/react-integration/hooks.spec.ts

For New Framework Wrappers (Vue, Angular, etc.)

  1. Create wrapper in src/{framework}/
  2. Add API tests in tests/{framework}-integration/
  3. Create example app in examples/{framework}-app/
  4. Add smoke test in tests/examples/{framework}-app.spec.ts

For New Example Apps

Create a simple smoke test in tests/examples/ that just verifies:

  • Example loads without errors
  • Main component renders
  • Basic interaction works

Don't duplicate all the feature tests - that's what tests/component/ is for!

Test Prerequisites

Component Tests

These run against http://localhost:5173 which should serve your component:

# Terminal 1: Build and serve your component
npm run build
# Or start dev server if configured

React Integration Tests

These require the React example to be running:

# Terminal 1: Start React example
cd examples/react-app
npm run dev

# Terminal 2: Run tests
cd ../..
npm run test:playwright -- --project=react-integration

CI/CD Recommendations

# Example GitHub Actions workflow
test:
  - npm run build
  - npm run test:playwright

Troubleshooting

React integration tests fail

Make sure the React example is running: cd examples/react-app && npm run dev

Tests are flaky

Increase timeout values in individual tests or adjust wait times for async operations.

Port conflicts

If localhost:5173 is in use, update playwright.config.ts to use a different port.

Testing Philosophy

This testing structure follows a hybrid approach:

🎯 Three Layers of Testing

  1. Component Tests (Thorough) - tests/component/

    • Test the web component exhaustively
    • All features, edge cases, configurations
    • This is your main test suite
  2. Integration Tests (API Focus) - tests/{framework}-integration/

    • Test framework wrapper APIs (hooks, context, etc.)
    • Verify the wrapper works in framework context
    • Don't re-test component features
  3. Example Smoke Tests (Light) - tests/examples/

    • Just verify examples load and render
    • Basic interaction works
    • Catch breaking changes in examples
    • NOT exhaustive feature testing

📊 Test Distribution

Component tests:     ████████████████████  80% of test effort
Integration tests:   ████████              15% of test effort
Example smoke tests: ██                     5% of test effort

✅ DO:

  • Test src/components/ thoroughly
  • Test src/react/ API thoroughly
  • Smoke test examples/ lightly

❌ DON'T:

  • Re-test component features in example tests
  • Make examples hard to change due to tests
  • Duplicate test logic across examples