All Projects → chaijs → chai

chaijs / chai

Licence: MIT license
BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to chai

Expect More
Curried Type Testing library, and Test Matchers for Jest
Stars: ✭ 124 (-98.42%)
Mutual labels:  tdd, bdd, assertions
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (-99.58%)
Mutual labels:  tdd, bdd, chai
Should.js
BDD style assertions for node.js -- test framework agnostic
Stars: ✭ 1,908 (-75.67%)
Mutual labels:  tdd, bdd, assertions
Should Enzyme
Useful functions for testing React Components with Enzyme.
Stars: ✭ 41 (-99.48%)
Mutual labels:  tdd, bdd, assertions
Postman Bdd
A BDD test framework for Postman and Newman
Stars: ✭ 139 (-98.23%)
Mutual labels:  bdd, assertions, chai
Pester
Pester is the ubiquitous test and mock framework for PowerShell.
Stars: ✭ 2,620 (-66.59%)
Mutual labels:  tdd, bdd, assertions
Cracking The Coding Interview Javascript Solutions Ctci
Javascript solutions to Cracking the Coding Interview (CTCI)
Stars: ✭ 139 (-98.23%)
Mutual labels:  tdd, chai
Qaf
Quality Automation Framework for web, mobileweb, mobile native and rest web-service using Selenium, webdrier, TestNG and Java Jersey
Stars: ✭ 150 (-98.09%)
Mutual labels:  tdd, bdd
Gunit
GUnit - Google.Test/Google.Mock/Cucumber on steroids
Stars: ✭ 156 (-98.01%)
Mutual labels:  tdd, bdd
Spek
A specification framework for Kotlin
Stars: ✭ 2,143 (-72.67%)
Mutual labels:  tdd, bdd
Jest Extended
Additional Jest matchers 🃏💪
Stars: ✭ 1,763 (-77.52%)
Mutual labels:  tdd, assertions
Karma
Spectacular Test Runner for JavaScript
Stars: ✭ 11,591 (+47.81%)
Mutual labels:  tdd, bdd
Nspec
A battle hardened testing framework for C# that's heavily inspired by Mocha and RSpec.
Stars: ✭ 242 (-96.91%)
Mutual labels:  tdd, bdd
Snap Shot It
Smarter snapshot utility for Mocha and BDD test runners + data-driven testing!
Stars: ✭ 138 (-98.24%)
Mutual labels:  tdd, bdd
Tester
Тестер 1С
Stars: ✭ 131 (-98.33%)
Mutual labels:  tdd, bdd
Radish
Behavior Driven Development tooling for Python. The root from red to green.
Stars: ✭ 153 (-98.05%)
Mutual labels:  tdd, bdd
Bandit
Human-friendly unit testing for C++11
Stars: ✭ 240 (-96.94%)
Mutual labels:  tdd, bdd
Catch2
A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
Stars: ✭ 14,330 (+82.73%)
Mutual labels:  tdd, bdd
Lightbdd
BDD framework allowing to create easy to read and maintain tests.
Stars: ✭ 195 (-97.51%)
Mutual labels:  tdd, bdd
Rgviperchat
An iOS chat app written following a VIPER architecture and BDD
Stars: ✭ 65 (-99.17%)
Mutual labels:  tdd, bdd

ChaiJS
chai

Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

license:mit tag:? node:?
Selenium Test Status
downloads:? build:? coverage:? devDependencies:?
Join the Slack chat Join the Gitter chat OpenCollective Backers

For more information or to download plugins, view the documentation.

What is Chai?

Chai is an assertion library, similar to Node's built-in assert. It makes testing much easier by giving you lots of assertions you can run against your code.

Installation

Node.js

chai is available on npm. To install it, type:

$ npm install --save-dev chai

Browsers

You can also use it within the browser; install via npm and use the chai.js file found within the download. For example:

<script src="./node_modules/chai/chai.js"></script>

Usage

Import the library in your code, and then pick one of the styles you'd like to use - either assert, expect or should:

var chai = require('chai');  
var assert = chai.assert;    // Using Assert style
var expect = chai.expect;    // Using Expect style
var should = chai.should();  // Using Should style

Pre-Native Modules Usage (registers the chai testing style globally)

require('chai/register-assert');  // Using Assert style
require('chai/register-expect');  // Using Expect style
require('chai/register-should');  // Using Should style

Pre-Native Modules Usage (as local variables)

const { assert } = require('chai');  // Using Assert style
const { expect } = require('chai');  // Using Expect style
const { should } = require('chai');  // Using Should style
should();  // Modifies `Object.prototype`

const { expect, use } = require('chai');  // Creates local variables `expect` and `use`; useful for plugin use

Native Modules Usage (registers the chai testing style globally)

import 'chai/register-assert';  // Using Assert style
import 'chai/register-expect';  // Using Expect style
import 'chai/register-should';  // Using Should style

Native Modules Usage (local import only)

import { assert } from 'chai';  // Using Assert style
import { expect } from 'chai';  // Using Expect style
import { should } from 'chai';  // Using Should style
should();  // Modifies `Object.prototype`

Usage with Mocha

mocha spec.js -r chai/register-assert  # Using Assert style
mocha spec.js -r chai/register-expect  # Using Expect style
mocha spec.js -r chai/register-should  # Using Should style

Read more about these styles in our docs.

Plugins

Chai offers a robust Plugin architecture for extending Chai's assertions and interfaces.

  • Need a plugin? View the official plugin list.
  • Want to build a plugin? Read the plugin api documentation.
  • Have a plugin and want it listed? Simply add the following keywords to your package.json:
    • chai-plugin
    • browser if your plugin works in the browser as well as Node.js
    • browser-only if your plugin does not work with Node.js

Related Projects

Contributing

Thank you very much for considering to contribute!

Please make sure you follow our Code Of Conduct and we also strongly recommend reading our Contributing Guide.

Here are a few issues other contributors frequently ran into when opening pull requests:

  • Please do not commit changes to the chai.js build. We do it once per release.
  • Before pushing your commits, please make sure you rebase them.

Contributors

Please see the full Contributors Graph for our list of contributors.

Core Contributors

Feel free to reach out to any of the core contributors with your questions or concerns. We will do our best to respond in a timely manner.

Jake Luer Veselin Todorov Keith Cirkel Lucas Fernandes da Costa Grant Snodgrass

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].