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

llm-as-a-jest

v1.0.5

Published

Jest plugin with LLM-as-a-Judge matchers basing on G-Eval, B-Eval, and LLM-Rubric

Downloads

126

Readme

llm-as-a-jest

A jest plugin for evaluating human messages, agent or LLM-generated answers using LLM-based criteria matchers: LLM-Rubric, G-Eval, B-Eval. This package fits for testing agentic systems, chatbots, or any text, where needs to check correctness, relevance, and safety with advanced possibilities of AI.


Quick start

npm install @eva-llm/llm-as-a-jest
{
  "setupFilesAfterEnv": ["@eva-llm/llm-as-a-jest/jest.setup"]
}
const SEC = 1000;

describe('llmAsJudge matcher', () => {

  it('should do smoke tests', async () => {
    const query = 'What is the capital of France?';
    const answer = 'Paris is the capital of France.';

    await expect(answer).gEval({
      criteria: 'answer should be factually correct',
    });

    await expect(answer).gEval({
      query,
      criteria: 'answer should be coherent to question',
    });

    await expect(answer).bEval({
      criteria: 'answer should be factually correct',
    });

    await expect(answer).bEval({
      query,
      criteria: 'answer should be coherent to question',
    });

    await expect(answer).llmRubric({
      criteria: 'answer should be factually correct',
    });
  }, 60 * SEC);
});

Matchers

  • llmRubric - Evaluates a text against a rubric using an LLM. Returns a reason, pass/fail, and normalized score.
  • gEval - Evaluates a text or query-answer pair against criteria and derived steps using an LLM. Returns a reason and normalized score (0.0-1.0).
  • bEval - Evaluates a text or query-answer pair against criteria and derived steps using an LLM, but with binary scoring (0 or 1). Returns a reason and a normalized score (0 or 1).

G-Eval vs B-Eval

The divergence between G-Eval and B-Eval reveals a critical 'Judgement Gap':

  • G-Eval (The Auditor): Scoring on a 0.0-1.0 scale allows the model to stay in a 'comfort zone', smoothing over internal contradictions.
  • B-Eval (The Judge): A binary 0|1 choice forces Adjudication. This 'forced choice' triggers the Alignment Paradox, exposing the struggle between RLHF training and objective facts.

B-Eval is a superior stress-test for Epistemic Honesty. By stripping away the safety net of grey-zone scoring, it reveals exactly where logic breaks under the weight of normative priors.

More details in Dark Teaming Manifesto.


Matcher Options

Matcher options parameter forward any Vercel AI SDK generateText options.

NOTE! Internal values such as model, system, and prompt are managed by the Judge and will override corresponding values in the options object to ensure evaluation integrity.

GEvalOptions (for G-Eval and B-Eval):

  • query (string, optional): The question for answer if to evaluate query-answer pair.
  • criteria (string | string[]): Criteria or rubric for evaluation. (required)
  • threshold (number, optional): Pass threshold (default: pluginConfig.threshold).
  • temperature (number, optional): LLM temperature (default: pluginConfig.temperature).
  • provider (string, optional): LLM provider to use (default: pluginConfig.provider).
  • model (string, optional): LLM model to use (default: pluginConfig.model).
  • verbose (boolean, optional): If needs to show non-truncated query and answer in failed test error (default: pluginConfig.verbose).
  • options (object, optional): Forwarded Vercel ai-sdk options (default: {}).

LLMRubricOptions (for LLM-Rubric):

  • criteria (string | string[]): Criteria or rubric for evaluation. (required)
  • threshold (number, optional): Pass threshold (default: pluginConfig.threshold).
  • temperature (number, optional): LLM temperature (default: pluginConfig.temperature).
  • provider (string, optional): LLM provider to use (default: pluginConfig.provider).
  • model (string, optional): LLM model to use (default: pluginConfig.model).
  • verbose (boolean, optional): If needs to show non-truncated query and answer in failed test error (default: pluginConfig.verbose).
  • options (object, optional): Forwarded Vercel ai-sdk options (default: {}).

Default Plugin Configuration

You can override the default plugin configuration using the configure function. The defaults are:

{
  provider: 'openai',
  model: 'gpt-4.1-mini',
  threshold: 0.5,
  temperature: 0.0, // Recommended for judging
  verbose: false, // truncated query and answer in failed test error
}

Call configure({ ... }) in your setup to change these values globally for all matchers.


LLM Providers and Settings

The following LLM providers are supported (via Vercel ai-sdk):

  • OpenAI (openai)
  • Anthropic (anthropic)
  • Google (google)
  • Mistral (mistral)
  • Amazon Bedrock (bedrock)
  • Azure (azure)
  • DeepSeek (deepseek)
  • Groq (groq)
  • Perplexity (perplexity)
  • xAI (xai)

Specify the provider name and model name in llmRubric, gEval, or bEval.

Note: Each provider integration is based on its respective ai-sdk package. Be sure to follow the provider's documentation for setup and authentication. Most providers require you to export an API key or token as an environment variable (e.g., export OPENAI_API_KEY=...).

More info about available providers and models in @eva-llm/eva-judge.