Top Git Project

Freecodecamp's open-source codebase and curriculum....


A declarative, efficient, and flexible JavaScript library...


An Open Source Machine Learning Framework for Everyone


The most popular HTML, CSS, and JavaScript framework for...

System design-primer

Learn how to design large-scale systems. Prep for the...


🙃 A delightful community-driven (with 1900+...


Flutter makes it easy and fast to build beautiful apps...


JavaScript Style Guide


All Algorithms implemented in Python


「Java学习+面试指南」一份涵盖大部分 Java 程序员所需要掌握的核心知识。准备 Java 面试,首选...


a TypeScript unit testing framework, following standard xUnit patterns

xunit.ts logo


A TypeScript unit testing framework, following standard xUnit patterns

npm version CI status Code Coverage

Maintainability Rating Reliability Rating Security Rating


Detailed documentation is available at

Quick Start


  • Node.js 14, 16, 18

    (other versions may work, but only the latest minor release for each LTS version is actively supported)

  • A supported TypeScript compiler

    • TypeScript v4
    • Vite v3
    • Rollup v3
    • Parcel v1
    • Webpack v5


npm install --dev xunit.ts


yarn add --dev xunit.ts

Configure your test project

At a minimum, your tsconfig.json will require the following:

    "compilerOptions": {
        "target": "ES2015", //or "ES6"
        "module": "CommonJS",
        "experimentalDecorators": true

If you're using a bundler, you'll need to declare xunit.ts as an external in your build config file for the tests to be detected. See the officially-supported configurations in the compiler-tests directory of the source code for detailed examples.

Create your first test


import { Test, TestSuite } from 'xunit.ts';

export default class MyTestSuite extends TestSuite {
    async MyFirstTest() {
        this.assert.equal(2, 1 + 1);

Run your tests

You'll first need to compile your TypeScript tests into JavaScript using tsc or the supported bundler of your choice.

Then run:

npm run xunit compiled_tests_dir


yarn xunit compiled_tests_dir

to run the tests.

You can also run xunit.ts from a script in your package.json:

    "scripts": {
        "test": "tsc --outDir compiled_tests_dir && xunit compiled_tests_dir"

Filtering tests

The xunit command can take one or more --filter flags (-f alias) followed by a regular expression to match TestSuiteName.TestMethodName. See the full documentation for more details.



By default, xunit.ts will output test results to stdout so they can be captured by your terminal, or piped elsewhere:

~/example $ npm run test

My Test Suite
  ✓ My First Test

    Passed: 1
     Total: 1

~/example $ _

Results can also be output in JUnit and Sonar XML formats, for import into other systems. See the full documentation for a list of all available output options.


xunit.ts has a built-in assertion library, accessible via this.assert... from within a TestSuite, or you can use your favorite third-party one: anything that uses Node.js' AssertionError is supported.

If you prefer, you can import { Assert } from 'xunit.ts and call e.g. Assert.true(expression); instead of this.assert.true(expression); for any included assertion.

See the full documentation for a list of all available assertions.


Please be sure to read and follow ecoAPM's Contribution Guidelines when submitting issues or pull requests.

Building / Testing locally

From the core directory:

  1. npm install or yarn install to download all dependencies
  2. npm run build or yarn build will compile xunit.ts and its tests to the dist directory
  3. npm run test or yarn test will run all unit tests in dist/tests
  4. npm run build && npm run test or yarn build && yarn test will build and run tests in a single step

Missing an assertion?

Create an issue or submit a pull request!

  1. Add a new function to core/src/Assertions
  2. Add tests for both the positive and negative cases in core/tests/Assertions
  3. Add a field for the assertion to core/src/Assertions/index.ts

Next saas-starter

⚡️ Free Next.js responsive landing page template for SaaS products made using JAMStack architecture.

Ts postgres

Non-blocking PostgreSQL client for Node.js written in TypeScript.


Fast and lightweight JavaScript game engine built on WebGL and glTF

Flamework gateways-mod

Implement Flamework remotes with classes


IOS Android Web cross platform app for real time collaborative music listening session and playlist editing. Using...


A social media platform to create communities and make friends