Which Platforms and Environments Can Chai Run In?
Updated
Chai runs in three environments listed on chaijs.com: Node, Browser, and Rails. The same assertion library is available across all three, so you can use one assertion style whether your tests execute in a Node.js process, in a browser, or inside a Rails application. The only condition is that you install or load the build intended for that platform — the site presents them as separate entry points rather than one universal bundle.
The three supported platforms
| Platform | What it means in practice |
|---|---|
| Node | Chai runs in a Node.js process, which covers server-side test runners and any test framework executing under Node. |
| Browser | Chai runs in the browser, so assertions can be made in tests that execute in a browser environment. |
| Rails | Rails is listed as a platform option alongside Node and Browser. |
The site's platform switcher labels these as "for Node," "for Browser," and "for Rails," each with links to the other two. That structure tells you the documentation is organized per platform, so setup instructions differ depending on which one you pick.
What stays the same across platforms
Chai describes itself as a BDD / TDD assertion library for Node and the browser that can be paired with any JavaScript testing framework. Two consequences follow:
- Framework independence. Chai is not tied to a specific test runner. It supplies assertions; the testing framework supplies the test structure and reporting.
- Interface choice is separate from platform choice. Chai offers several interfaces so the developer can pick the most comfortable one. The chain-capable BDD styles provide an expressive, readable language for assertions. This choice applies regardless of whether you are running in Node, a browser, or Rails.
Plugins and extension
Plugins extend Chai's assertions to new contexts such as vendor integration and object construction, and developers can build their own plugins to share with the community. If your target platform needs assertions Chai does not ship by default, a plugin is the intended extension path rather than a platform limitation.
How to decide
- Testing server-side JavaScript or a Node-based test runner → use the Node build.
- Testing code that executes in a browser → use the Browser build.
- Working inside a Rails application → Rails is listed as a supported platform; follow the Rails-specific setup rather than assuming the Node instructions apply.
If you are unsure, start from the platform switcher on chaijs.com and read the page for the environment your tests actually run in — the assertion interfaces and plugin model carry over, but the loading and installation steps are platform-specific.