agentsclimarketplace

Chai

Skill G1Joshi/Agent-Skills/skills/testing/chai

Chai assertion library for JavaScript. Use for JS assertions.From its SKILL.md

Install
npx -y skills add G1Joshi/Agent-Skills --skill chai

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.4 KB, 362 tokens by cl100k_base, as published. Nobody here has run it

Chai

Chai is an assertion library. It pairs naturally with Mocha. It supports TDD (assert) and BDD (expect, should) styles.

When to Use

  • With Mocha: The default pair.
  • Expressive Tests: You want tests to read like English ("expect foo to be a string").

Quick Start

import { expect } from "chai";

const foo = "bar";
const beverages = { tea: ["chai", "matcha", "oolong"] };

expect(foo).to.be.a("string");
expect(foo).to.equal("bar");
expect(foo).to.have.lengthOf(3);
expect(beverages).to.have.property("tea").with.lengthOf(3);

Core Concepts

Styles

  • Assert: Classic. assert.equal(foo, 'bar').
  • Expect: BDD. Chainable. expect(foo).to.be.equal('bar').
  • Should: BDD. Extends Object prototype. foo.should.be.equal('bar'). (Less common now due to side effects).

Plugins

Chai has a rich ecosystem.

  • chai-http: For API testing.
  • chai-as-promised: For asserting promises (return expect(promise).to.eventually.equal(2)).

Best Practices (2025)

Do:

  • Stick to one style: Usually Expect. It's clean and doesn't modify prototypes.
  • Use Descriptive Chains: to.be.true reads better than to.equal(true).

Don't:

  • Don't mix Assert and Expect: Confuses the reader.

References

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.