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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@noredink/cypress-ai-assert

v1.0.1

Published

Cypress custom command to validate text with LLMs (Anthropic, OpenAI, etc).

Readme

@noredink/cypress-ai-assert

Make assertions by calling any LLM's API inside tests.

Setup

Install using npm:

npm install --save-dev @noredink/cypress-ai-assert

Require from commands.js

require('@noredink/cypress-ai-assert')

Or ES module syntax:

import '@noredink/cypress-ai-assert'

For TypeScript, add to tsconfig.json

{
  "compilerOptions": {
    "types": ["cypress", "@noredink/cypress-ai-assert"]
  }
}

Configuration

Other than the mock provider used in the package's tests, you need an API key for an LLM to use the package. To use one of the two built-in LLM providers, make sure to set Cypress.env('ANTHROPIC_API_KEY') or Cypress.env('OPENAI_API_KEY') to a valid Anthropic or OpenAI API key.

Usage

Basic (defaults to Anthropic)

cy.get('#definition-container').aiAssert('Check if the text is in Spanish')

Get the LLM's full thinking as debug output in the test runner

cy.get('#sponsored-content').aiAssert('Should contain sponsored ads with links to external sites', { debug: true })

Specify a different provider

cy.get('body').aiAssert('The page should show a comparison of the free, Premium, and Enterprise versions', { provider: 'openai' })

Specify a custom provider (assumes you have registered a 'gemini' provider not included in this package)

cy.get('body').aiAssert('The page should show a comparison of the free, Premium, and Enterprise versions', { provider: 'gemini' })

Registering your own provider

Register your own provider

import { registerProvider } from '@noredink/cypress-ai-assert'

// Example: Google Gemini
registerProvider({
  name: 'gemini',
  request: async (instruction, content, options) => {
    const response = await fetch('https://gemini.googleapis.com/v1/text', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${options.apiKey}`
      },
      body: JSON.stringify({ instruction, content })
    })

    const json = await response.json()
    return json.output
  }
})

And call it in tests

cy.get('#some-element').aiAssert('Should contain text', {
  provider: 'gemini',
  apiKey: 'my-api-key' // custom per-provider option
})

The Mock Provider

The mock provider is built-in for testing. It may be useful if you want to temporarily suspend making live LLM calls while working on something, or for testing changes to this package, etc.

cy.get('#some-element').aiAssert('Some assertion', {
  provider: 'mock',
  force: 'YES' // or 'NO' to simulate a failure
})

It can also accept the debug option and return some fake thinking.

Contributing

Community contributions are welcome. If you're not sure if your idea would be appropriate for this package, feel free to open an issue describing your change before making a PR.