ElasticDash Test Runner

0.1.19 · active · verified Sun Apr 19

elasticdash-test is an AI-native test runner specifically designed for testing ElasticDash workflows. Currently in early development at version 0.1.19, it provides capabilities for defining, executing, and potentially generating tests with AI assistance, tailored for the ElasticDash ecosystem. Given its `0.x` version, users should expect frequent updates and potential breaking changes as the API and features evolve rapidly. The package differentiates itself by integrating AI directly into the testing process, aiming to streamline workflow validation within ElasticDash environments, contrasting with general-purpose test runners by focusing on this specific use case and its associated data and API structures.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates defining a test suite for a user management workflow, including global configuration and basic assertions against simulated ElasticDash API interactions. It highlights the use of `test`, `describe`, and `configure`.

import { test, describe, expect, configure } from 'elasticdash-test';

// Configure the test runner with your ElasticDash API key
// It's recommended to load this from environment variables.
configure({
  apiKey: process.env.ELASTICDASH_API_KEY ?? '',
  endpoint: process.env.ELASTICDASH_API_ENDPOINT ?? 'https://api.elasticdash.com'
});

describe('User Management Workflow', () => {
  test('should create a new user successfully', async () => {
    // Simulate interaction with an ElasticDash workflow or API
    // In a real scenario, this would involve calling the ElasticDash API client
    const newUser = { id: 'user-123', name: 'John Doe', email: 'john.doe@example.com' };
    const response = await simulateCreateUser(newUser);

    expect(response.status).toBe(200);
    expect(response.body.message).toBe('User created');
    expect(response.body.user.name).toBe('John Doe');
  });

  test('should retrieve an existing user', async () => {
    const userId = 'user-456';
    const user = await simulateGetUser(userId);

    expect(user).not.toBeNull();
    expect(user.id).toBe(userId);
    expect(user.name).toBe('Jane Doe');
  });
});

async function simulateCreateUser(user: any) {
  // Placeholder for actual ElasticDash API call
  return Promise.resolve({
    status: 200,
    body: { message: 'User created', user }
  });
}

async function simulateGetUser(id: string) {
  // Placeholder for actual ElasticDash API call
  if (id === 'user-456') {
    return Promise.resolve({ id: 'user-456', name: 'Jane Doe', email: 'jane.doe@example.com' });
  }
  return Promise.resolve(null);
}

// To run:
// 1. Save as 'user.test.ts'
// 2. Set ELASTICDASH_API_KEY and ELASTICDASH_API_ENDPOINT environment variables
// 3. Run: npx elasticdash-test user.test.ts

view raw JSON →