Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

License

NotificationsYou must be signed in to change notification settings

chaijs/chai

Repository files navigation

ChaiJS
chai

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

downloads:?node:?
Join the Slack chatJoin the Gitter chatOpenCollective Backers

For more information or to download plugins, view thedocumentation.

What is Chai?

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

Installation

Node.js

chai is available onnpm. To install it, type:

$ npm install --save-dev chai

Browsers

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

<scriptsrc="./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 - eitherassert,expect orshould:

import{assert}from'chai';// Using Assert styleimport{expect}from'chai';// Using Expect styleimport{should}from'chai';// Using Should style

Register the chai testing style globally

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

Import assertion styles as local variables

import{assert}from'chai';// Using Assert styleimport{expect}from'chai';// Using Expect styleimport{should}from'chai';// Using Should styleshould();// Modifies `Object.prototype`import{expect,use}from'chai';// Creates local variables `expect` and `use`; useful for plugin use

Usage with Mocha

mocha spec.js --require chai/register-assert.js# Using Assert stylemocha spec.js --require chai/register-expect.js# Using Expect stylemocha spec.js --require chai/register-should.js# 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 theofficial plugin list.
  • Want to build a plugin? Read theplugin 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 ourCode Of Conduct and we also strongly recommend reading ourContributing Guide.

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

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

Contributors

Please see the fullContributors Graph for ourlist of contributors.

Core Contributors

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

Jake LuerVeselin TodorovKeith CirkelLucas Fernandes da CostaGrant Snodgrass

About

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

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    [8]ページ先頭

    ©2009-2025 Movatter.jp