0.1.10 • Published 4 years ago

@cursed/spec v0.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@cursed/spec

A simple test framework with sane defaults.

Installing @cursed/spec

In your project, run npm install @cursed/spec --save-dev

Usage

Create a test directory.

Create the test/index.ts with the following:

import Spec from "@cursed/spec";

Spec.importTests(__dirname).then(() => Spec.run());

Now, test files in test that end in Test.ts or Test.js will be imported and run.

If using TypeScript, you can run the tests via npx ts-node test/index.ts

If using JavaScript, you can run the tests via node test/index.js

Defining a Test

The default export of @cursed/spec is an instance of Runner so you can import Spec from "@cursed/spec" and immediately begin writing tests:

// test/myTest.ts
import Spec, { assert } from "@cursed/spec";

let instance;
Spec.describe("MyClass", (c) => {
  c.beforeEach(() => {
    instance = new MyClass();
  });

  c.test("it does something", async () => {
    await instance.perform();

    assert(instance.ran);
    assert.equal(1, instance.runCount);
  });
});
0.1.10

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.4

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago