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

@mifistix-cloud/rules-unit-testing

v2.0.5

Published

Rules Unit Testing SDK for Mifistix Cloud - Test security rules with authenticated/unauthenticated contexts

Readme

@mifistix-cloud/rules-unit-testing

Rules Unit Testing SDK for Mifistix Cloud - Test security rules with authenticated/unauthenticated contexts.

License

This module is licensed for internal use within Mifistix only. See LICENSE for details.

Installation

npm install @mifistix-cloud/rules-unit-testing

Quick Start

const { initializeTestEnvironment, assertSucceeds, assertFails } = require('@mifistix-cloud/rules-unit-testing');

// Initialize test environment
const env = await initializeTestEnvironment({
  projectId: 'your-project-id',
  serverUrl: 'https://api-cloud.s-mifistix.pp.ua'
});

// Get authenticated context
const adminCtx = env.authenticatedContext('admin-user-123', { role: 'admin' });

// Get unauthenticated context
const anonCtx = env.unauthenticatedContext();

// Test that operation succeeds
await assertSucceeds(adminCtx.database.ref('admin/data').set({ secret: 'value' }));

// Test that operation fails
await assertFails(anonCtx.database.ref('admin/data').get());

// Cleanup
await env.cleanup();

API Reference

initializeTestEnvironment(config)

Initialize test environment.

Parameters:

  • config (Object, required)
    • projectId (string, required): Project ID (validated)
    • serverUrl (string, optional): Custom server URL

Returns: Test environment instance

Example:

const env = await initializeTestEnvironment({
  projectId: 'project-123'
});

env.authenticatedContext(uid, customClaims?)

Get context for authenticated user.

Parameters:

  • uid (string, required): User ID
  • customClaims (Object, optional): Custom claims object

Returns: Test context with auth user and database interface

Example:

const ctx = env.authenticatedContext('user-123', { role: 'admin' });

env.unauthenticatedContext()

Get context for unauthenticated request.

Returns: Test context without auth user

Example:

const ctx = env.unauthenticatedContext();

assertSucceeds(promise)

Assert that operation succeeds (status < 400).

Parameters:

  • promise (Promise): Operation to test

Returns: Promise with result

Throws: Error if operation fails

Example:

await assertSucceeds(ctx.database.ref('public/data').set({ key: 'value' }));

assertFails(promise)

Assert that operation fails (status >= 400).

Parameters:

  • promise (Promise): Operation to test

Returns: Promise with result

Throws: Error if operation succeeds

Example:

await assertFails(ctx.database.ref('private/data').get());

env.cleanup()

Cleanup test environment.

Returns: Promise

Test Context

The test context provides a database interface with auth context:

const ctx = env.authenticatedContext('user-123');

// Database operations with auth context
await ctx.database.ref('path').set({ data: 'value' });
await ctx.database.ref('path').get();

Security Features

  • Project ID Validation: Validates project ID on initialization
  • Auth Context: Properly includes auth headers in requests
  • Error Handling: Throws ValidationError for invalid configuration

Usage Pattern

const env = await initializeTestEnvironment({ projectId: 'test-project' });

// Test admin operations
const admin = env.authenticatedContext('admin', { role: 'admin' });
await assertSucceeds(admin.database.ref('admin/data').set({ key: 'value' }));

// Test public operations
const anon = env.unauthenticatedContext();
await assertSucceeds(anon.database.ref('public/data').get());

// Test private operations fail for anon
await assertFails(anon.database.ref('private/data').get());

await env.cleanup();

Architecture

rules-unit-testing/
├── src/
│   ├── core/
│   │   └── TestingEnvironment.js # Test environment
│   ├── services/
│   │   └── TestContext.js        # Test context with auth
│   ├── utils/
│   │   └── helpers.js          # Helper functions
│   ├── types/
│   │   └── index.js            # Type definitions
│   └── config/
│       └── constants.js        # Configuration constants
└── index.js

License

MIT