RagLeap
Tests

Tests: @ragleap/rag (npm, TypeScript)

Test files: 20. Test functions: 158. Described by their authors (docstring or @DisplayName): 0. Where there is no description, the line shows the test name in words and says so.

Latest result: no job named ragleap-rag-js-tests in the latest CI run

cache.test.mjs — 6 tests

No file-level description in the source.

  • cache miss followed by hit
    Cache miss followed by hit (no description in the source; shown from the name)
  • cache key includes the embedding model
    Cache key includes the embedding model (no description in the source; shown from the name)
  • cache evicts the least recently used entry
    Cache evicts the least recently used entry (no description in the source; shown from the name)
  • updating an entry refreshes it without duplicating it
    Updating an entry refreshes it without duplicating it (no description in the source; shown from the name)
  • clear resets entries and statistics
    Clear resets entries and statistics (no description in the source; shown from the name)
  • empty cache has a zero hit rate
    Empty cache has a zero hit rate (no description in the source; shown from the name)
chunker.test.mjs — 5 tests

No file-level description in the source.

  • chunks use the expected overlapping windows
    Chunks use the expected overlapping windows (no description in the source; shown from the name)
  • empty and whitespace-only inputs return no chunks
    Empty and whitespace-only inputs return no chunks (no description in the source; shown from the name)
  • overlap equal to chunk size throws
    Overlap equal to chunk size throws (no description in the source; shown from the name)
  • fallback counts whitespace-separated words and is inexact
    Fallback counts whitespace-separated words and is inexact (no description in the source; shown from the name)
  • factory creates a configured chunker
    Factory creates a configured chunker (no description in the source; shown from the name)
contextual-rewrite.test.mjs — 5 tests

No file-level description in the source.

  • returns original query without an LLM call when history is empty
    Returns original query without an LLM call when history is empty (no description in the source; shown from the name)
  • uses the Python prompt and returns the trimmed standalone question
    Uses the Python prompt and returns the trimmed standalone question (no description in the source; shown from the name)
  • forwards the provider override
    Forwards the provider override (no description in the source; shown from the name)
  • uses original query when generated answer is empty
    Uses original query when generated answer is empty (no description in the source; shown from the name)
  • falls back to original query and null result on generation failure
    Falls back to original query and null result on generation failure (no description in the source; shown from the name)
cost.test.mjs — 8 tests

No file-level description in the source.

  • computes cost from known model rates
    Computes cost from known model rates (no description in the source; shown from the name)
  • unknown provider, unknown model, or missing usage returns null
    Unknown provider, unknown model, or missing usage returns null (no description in the source; shown from the name)
  • Ollama wildcard rates calculate zero cost
    Ollama wildcard rates calculate zero cost (no description in the source; shown from the name)
  • custom rates override one model without deleting other seed rates
    Custom rates override one model without deleting other seed rates (no description in the source; shown from the name)
  • tracker accumulates known costs but ignores unknown prices
    Tracker accumulates known costs but ignores unknown prices (no description in the source; shown from the name)
  • budget status changes when cumulative cost reaches threshold
    Budget status changes when cumulative cost reaches threshold (no description in the source; shown from the name)
  • no budget configured means never over budget
    No budget configured means never over budget (no description in the source; shown from the name)
  • exports pricing-table verification date
    Exports pricing-table verification date (no description in the source; shown from the name)
embedding.test.mjs — 11 tests

No file-level description in the source.

  • provider defaults and provider name normalization
    Provider defaults and provider name normalization (no description in the source; shown from the name)
  • requires a model, dimensions and API key where applicable
    Requires a model, dimensions and API key where applicable (no description in the source; shown from the name)
  • rejects inherited object property names as providers
    Rejects inherited object property names as providers (no description in the source; shown from the name)
  • custom provider requires an endpoint
    Custom provider requires an endpoint (no description in the source; shown from the name)
  • OpenAI-compatible single embedding sends dimensions only to OpenAI
    Open AI-compatible single embedding sends dimensions only to Open AI (no description in the source; shown from the name)
  • OpenAI-compatible batch preserves returned vector order
    Open AI-compatible batch preserves returned vector order (no description in the source; shown from the name)
  • Cohere honors custom base_url and uses search_document
    Cohere honors custom base url and uses search document (no description in the source; shown from the name)
  • Voyage honors custom base_url
    Voyage honors custom base url (no description in the source; shown from the name)
  • Gemini single and batch requests parse vectors
    Gemini single and batch requests parse vectors (no description in the source; shown from the name)
  • empty input and failures match Python return conventions
    Empty input and failures match Python return conventions (no description in the source; shown from the name)
  • malformed provider vector is treated as an embedding failure
    Malformed provider vector is treated as an embedding failure (no description in the source; shown from the name)
generation.test.mjs — 20 tests

No file-level description in the source.

  • provider configuration normalizes names and requires explicit models
    Provider configuration normalizes names and requires explicit models (no description in the source; shown from the name)
  • answer includes source citations, usage, and context budget
    Answer includes source citations, usage, and context budget (no description in the source; shown from the name)
  • provider failure falls back; override bypasses configured fallback
    Provider failure falls back; override bypasses configured fallback (no description in the source; shown from the name)
  • structured response reports validation and enforcement
    Structured response reports validation and enforcement (no description in the source; shown from the name)
  • all provider failures return the Python-compatible failure shape
    All provider failures return the Python-compatible failure shape (no description in the source; shown from the name)
  • streaming parses OpenAI-compatible SSE chunks
    Streaming parses Open AI-compatible SSE chunks (no description in the source; shown from the name)
  • stream parser handles final OpenAI event without trailing newline
    Stream parser handles final Open AI event without trailing newline (no description in the source; shown from the name)
  • stream parser handles final Gemini event without trailing newline
    Stream parser handles final Gemini event without trailing newline (no description in the source; shown from the name)
  • stream parser handles Anthropic text delta events
    Stream parser handles Anthropic text delta events (no description in the source; shown from the name)
  • stream parser handles events split across network chunks
    Stream parser handles events split across network chunks (no description in the source; shown from the name)
  • empty OpenAI-compatible answer does not trigger provider fallback
    Empty Open AI-compatible answer does not trigger provider fallback (no description in the source; shown from the name)
  • empty Gemini answer uses the Python-compatible result
    Empty Gemini answer uses the Python-compatible result (no description in the source; shown from the name)
  • empty Anthropic answer uses the Python-compatible result
    Empty Anthropic answer uses the Python-compatible result (no description in the source; shown from the name)
  • Anthropic structured tool input is validated as an object
    Anthropic structured tool input is validated as an object (no description in the source; shown from the name)
  • describe_image requires a Gemini provider in the chain
    Describe image requires a Gemini provider in the chain (no description in the source; shown from the name)
  • generation result includes cost for a model with known seed pricing
    Generation result includes cost for a model with known seed pricing (no description in the source; shown from the name)
  • generation result cost is null for unknown pricing and missing usage
    Generation result cost is null for unknown pricing and missing usage (no description in the source; shown from the name)
  • generation service supports custom pricing
    Generation service supports custom pricing (no description in the source; shown from the name)
  • configured CostTracker accumulates successful generation costs
    Configured Cost Tracker accumulates successful generation costs (no description in the source; shown from the name)
  • failed generation returns null cost and does not update CostTracker
    Failed generation returns null cost and does not update Cost Tracker (no description in the source; shown from the name)
hyde-document.test.mjs — 4 tests

No file-level description in the source.

  • uses the exact Python prompt and returns the trimmed passage
    Uses the exact Python prompt and returns the trimmed passage (no description in the source; shown from the name)
  • forwards the optional provider override
    Forwards the optional provider override (no description in the source; shown from the name)
  • falls back to the original query when generated answer is empty
    Falls back to the original query when generated answer is empty (no description in the source; shown from the name)
  • falls back to original query and null result on generation exception
    Falls back to original query and null result on generation exception (no description in the source; shown from the name)
ingestion.test.mjs — 11 tests

No file-level description in the source.

  • ingests chunks and emits the success event
    Ingests chunks and emits the success event (no description in the source; shown from the name)
  • rejects empty input before writing to storage
    Rejects empty input before writing to storage (no description in the source; shown from the name)
  • cleans up when all embeddings fail
    Cleans up when all embeddings fail (no description in the source; shown from the name)
  • cleans up after a chunk storage error and preserves the original error
    Cleans up after a chunk storage error and preserves the original error (no description in the source; shown from the name)
  • runs guardrails in order and supports disabling sanitization
    Runs guardrails in order and supports disabling sanitization (no description in the source; shown from the name)
  • update_document preserves the existing filename and creates a new ID
    Update document preserves the existing filename and creates a new ID (no description in the source; shown from the name)
  • update_document uses an explicitly supplied replacement filename
    Update document uses an explicitly supplied replacement filename (no description in the source; shown from the name)
  • update_document rejects a missing document before deleting anything
    Update document rejects a missing document before deleting anything (no description in the source; shown from the name)
  • update_document deletes the old document before replacement ingestion
    Update document deletes the old document before replacement ingestion (no description in the source; shown from the name)
  • a throwing guardrail aborts before any storage writes
    A throwing guardrail aborts before any storage writes (no description in the source; shown from the name)
  • null metadata is normalized for document and chunk storage
    Null metadata is normalized for document and chunk storage (no description in the source; shown from the name)
memory.test.mjs — 11 tests

No file-level description in the source.

  • exports the default history limit
    Exports the default history limit (no description in the source; shown from the name)
  • constructor validates the history limit
    Constructor validates the history limit (no description in the source; shown from the name)
  • add_message ensures a session and inserts the message
    Add message ensures a session and inserts the message (no description in the source; shown from the name)
  • add_message rolls back on insert failure and releases the client
    Add message rolls back on insert failure and releases the client (no description in the source; shown from the name)
  • add_message rejects invalid roles
    Add message rejects invalid roles (no description in the source; shown from the name)
  • get_history returns recent messages in chronological order
    Get history returns recent messages in chronological order (no description in the source; shown from the name)
  • get_history supports an explicit limit and zero limit
    Get history supports an explicit limit and zero limit (no description in the source; shown from the name)
  • get_history rejects invalid limits
    Get history rejects invalid limits (no description in the source; shown from the name)
  • clear_session deletes the conversation row
    Clear session deletes the conversation row (no description in the source; shown from the name)
  • build_history_prompt formats prior messages
    Build history prompt formats prior messages (no description in the source; shown from the name)
  • build_history_prompt returns empty text when history is empty
    Build history prompt returns empty text when history is empty (no description in the source; shown from the name)
multi-query.test.mjs — 4 tests

No file-level description in the source.

  • includes original query first and removes blank, duplicate, and marked lines
    Includes original query first and removes blank, duplicate, and marked lines (no description in the source; shown from the name)
  • respects n as the maximum total variant count
    Respects n as the maximum total variant count (no description in the source; shown from the name)
  • returns only the original query when generation throws
    Returns only the original query when generation throws (no description in the source; shown from the name)
  • handles empty generation output and zero variants
    Handles empty generation output and zero variants (no description in the source; shown from the name)
observability.test.mjs — 3 tests

No file-level description in the source.

  • handlers run in order and receive the event
    Handlers run in order and receive the event (no description in the source; shown from the name)
  • a broken handler does not stop later handlers
    A broken handler does not stop later handlers (no description in the source; shown from the name)
  • missing or empty handlers are a no-op
    Missing or empty handlers are a no-op (no description in the source; shown from the name)
pgvector.test.mjs — 15 tests

No file-level description in the source.

  • exports expected defaults
    Exports expected defaults (no description in the source; shown from the name)
  • constructor requires a database URL or injected pool
    Constructor requires a database URL or injected pool (no description in the source; shown from the name)
  • schema initialization validates dimensions and records successful setup
    Schema initialization validates dimensions and records successful setup (no description in the source; shown from the name)
  • dense search uses valid placeholders without metadata filter
    Dense search uses valid placeholders without metadata filter (no description in the source; shown from the name)
  • dense search uses valid placeholders with metadata filter
    Dense search uses valid placeholders with metadata filter (no description in the source; shown from the name)
  • dense search filters by document_id and metadata with correct placeholders
    Dense search filters by document id and metadata with correct placeholders (no description in the source; shown from the name)
  • dense search rejects mismatched dimensions and non-finite vectors
    Dense search rejects mismatched dimensions and non-finite vectors (no description in the source; shown from the name)
  • dense search filters scores below minimum similarity
    Dense search filters scores below minimum similarity (no description in the source; shown from the name)
  • sparse search builds full-text query and optional metadata filter
    Sparse search builds full-text query and optional metadata filter (no description in the source; shown from the name)
  • sparse search applies document_id and metadata filters
    Sparse search applies document id and metadata filters (no description in the source; shown from the name)
  • hybrid search combines dense and sparse ranks with reciprocal rank fusion
    Hybrid search combines dense and sparse ranks with reciprocal rank fusion (no description in the source; shown from the name)
  • hybrid search forwards document_id to dense and sparse searches
    Hybrid search forwards document id to dense and sparse searches (no description in the source; shown from the name)
  • empty searches return without querying the pool
    Empty searches return without querying the pool (no description in the source; shown from the name)
  • document CRUD methods map database rows
    Document CRUD methods map database rows (no description in the source; shown from the name)
  • injected pool is not closed by backend.close()
    Injected pool is not closed by backend.close() (no description in the source; shown from the name)
query-rewrite.test.mjs — 5 tests

No file-level description in the source.

  • RRF combines scores using zero-based ranks and default k=60
    RRF combines scores using zero-based ranks and default k=60 (no description in the source; shown from the name)
  • RRF keeps the first object for duplicate chunk IDs
    RRF keeps the first object for duplicate chunk IDs (no description in the source; shown from the name)
  • RRF falls back to document ID and chunk index
    RRF falls back to document ID and chunk index (no description in the source; shown from the name)
  • RRF preserves encounter order when scores tie
    RRF preserves encounter order when scores tie (no description in the source; shown from the name)
  • RRF supports a custom k and empty ranked lists
    RRF supports a custom k and empty ranked lists (no description in the source; shown from the name)
ragleap.test.mjs — 20 tests

No file-level description in the source.

  • initializes the vector backend using the configured embedding dimensions
    Initializes the vector backend using the configured embedding dimensions (no description in the source; shown from the name)
  • retrieves with hybrid search and reuses cached query embeddings
    Retrieves with hybrid search and reuses cached query embeddings (no description in the source; shown from the name)
  • uses dense search when hybrid search is disabled
    Uses dense search when hybrid search is disabled (no description in the source; shown from the name)
  • uses dense search when the backend has no hybrid implementation
    Uses dense search when the backend has no hybrid implementation (no description in the source; shown from the name)
  • does not embed or search when top_k is zero
    Does not embed or search when top k is zero (no description in the source; shown from the name)
  • rejects empty queries and invalid top_k values
    Rejects empty queries and invalid top k values (no description in the source; shown from the name)
  • throws when query embedding fails
    Throws when query embedding fails (no description in the source; shown from the name)
  • ask passes retrieved chunks and generation options, then applies output guardrails
    Ask passes retrieved chunks and generation options, then applies output guardrails (no description in the source; shown from the name)
  • input guardrails are applied during facade ingestion
    Input guardrails are applied during facade ingestion (no description in the source; shown from the name)
  • fires query and answer callbacks
    Fires query and answer callbacks (no description in the source; shown from the name)
  • disabled cache reports empty statistics and embeds every query
    Disabled cache reports empty statistics and embeds every query (no description in the source; shown from the name)
  • validates configured dimensions
    Validates configured dimensions (no description in the source; shown from the name)
  • close forwards to a backend close method
    Close forwards to a backend close method (no description in the source; shown from the name)
  • static database schema initializer executes the combined schema
    Static database schema initializer executes the combined schema (no description in the source; shown from the name)
  • ask loads session history and persists the successful exchange
    Ask loads session history and persists the successful exchange (no description in the source; shown from the name)
  • ask does not use or persist memory without a session id
    Ask does not use or persist memory without a session id (no description in the source; shown from the name)
  • ask does not persist an exchange when generation fails
    Ask does not persist an exchange when generation fails (no description in the source; shown from the name)
  • with_pgvector shares an injected pool with conversation memory
    With pgvector shares an injected pool with conversation memory (no description in the source; shown from the name)
  • with_pgvector preserves explicitly supplied conversation memory
    With pgvector preserves explicitly supplied conversation memory (no description in the source; shown from the name)
  • with_pgvector rejects missing database URL and pool
    With pgvector rejects missing database URL and pool (no description in the source; shown from the name)
reranking.test.mjs — 7 tests

No file-level description in the source.

  • uses the Python-compatible default model repository
    Uses the Python-compatible default model repository (no description in the source; shown from the name)
  • empty input returns the same array without loading a model
    Empty input returns the same array without loading a model (no description in the source; shown from the name)
  • scores chunks, mutates rerank_score, and sorts descending
    Scores chunks, mutates rerank score, and sorts descending (no description in the source; shown from the name)
  • top_k limits returned chunks after scoring all candidates
    Top k limits returned chunks after scoring all candidates (no description in the source; shown from the name)
  • zero top_k returns no chunks but still scores candidates
    Zero top k returns no chunks but still scores candidates (no description in the source; shown from the name)
  • rejects non-finite scores
    Rejects non-finite scores (no description in the source; shown from the name)
  • propagates scorer errors
    Propagates scorer errors (no description in the source; shown from the name)
sanitization.test.mjs — 5 tests

No file-level description in the source.

  • removes control and format characters but keeps newline and tab
    Removes control and format characters but keeps newline and tab (no description in the source; shown from the name)
  • normal and empty text remain unchanged
    Normal and empty text remain unchanged (no description in the source; shown from the name)
  • detects known injection phrases case-insensitively
    Detects known injection phrases case-insensitively (no description in the source; shown from the name)
  • clean and empty text return no injection matches
    Clean and empty text return no injection matches (no description in the source; shown from the name)
  • checks length using Unicode code points like Python
    Checks length using Unicode code points like Python (no description in the source; shown from the name)
schema.test.mjs — 7 tests

No file-level description in the source.

  • core schema contains document, chunk, vector, and search indexes
    Core schema contains document, chunk, vector, and search indexes (no description in the source; shown from the name)
  • core schema rejects invalid dimensions
    Core schema rejects invalid dimensions (no description in the source; shown from the name)
  • memory schema matches the required conversation tables
    Memory schema matches the required conversation tables (no description in the source; shown from the name)
  • combined schema includes both core and memory schema
    Combined schema includes both core and memory schema (no description in the source; shown from the name)
  • init_core_schema runs only core schema
    Init core schema runs only core schema (no description in the source; shown from the name)
  • init_memory_schema runs only memory schema
    Init memory schema runs only memory schema (no description in the source; shown from the name)
  • init_schema initializes core and memory schema separately
    Init schema initializes core and memory schema separately (no description in the source; shown from the name)
smoke.test.mjs — 1 tests

No file-level description in the source.

  • TypeScript package builds and exports its version
    Type Script package builds and exports its version (no description in the source; shown from the name)
structured.test.mjs — 7 tests

No file-level description in the source.

  • valid JSON is parsed and checked against the top-level type
    Valid JSON is parsed and checked against the top-level type (no description in the source; shown from the name)
  • fallback does not claim to validate nested required fields
    Fallback does not claim to validate nested required fields (no description in the source; shown from the name)
  • fallback catches top-level type mismatches
    Fallback catches top-level type mismatches (no description in the source; shown from the name)
  • malformed JSON returns null and false
    Malformed JSON returns null and false (no description in the source; shown from the name)
  • already-parsed objects are supported
    Already-parsed objects are supported (no description in the source; shown from the name)
  • registered validator performs full validation and failures preserve parsed data
    Registered validator performs full validation and failures preserve parsed data (no description in the source; shown from the name)
  • validator can be reset
    Validator can be reset (no description in the source; shown from the name)
vectorstores.test.mjs — 3 tests

No file-level description in the source.

  • sparse search defaults to unsupported
    Sparse search defaults to unsupported (no description in the source; shown from the name)
  • sparse capability is respected when explicitly enabled
    Sparse capability is respected when explicitly enabled (no description in the source; shown from the name)
  • hybrid fallback delegates to dense search
    Hybrid fallback delegates to dense search (no description in the source; shown from the name)

Compiled by script from the public repository, its CI logs and the GitHub API. To correct something, open an issue.

All tests