Skip to content

testingrequired/bespin

Repository files navigation

🌌 bespin

A test framework engine.

CI

Goals

  • Extendable
  • Easy to understand

Architecture

Usage

Install

The first step is installing the core library and cli application

$ npm install -D @testingrequired/bespin-cli

Config File

This provides the foundation for the framework but it still needs to know how to locate test files, parse them and run them.

$ npm install -D @testingrequired/bespin-glob-test-file-locator @testingrequired/bespin-spec-test-file-parser @testingrequired/bespin-serial-runner

These will provide finding test files using a glob pattern (e.g. **/*.test.js), parse test files with a describe/it/beforeEach syntax and execute the tests in parallel.

Now create a configuration file called bespin.config.js at your project root:

const { Config } = require("@testingrequired/bespin-core");
const {
  GlobTestFileLocator,
} = require("@testingrequired/bespin-glob-test-file-locator");
const {
  SpecTestFileParse,
} = require("@testingrequired/bespin-spec-test-file-parser");
const { AsyncRunner } = require("@testingrequired/bespin-async-runner");

module.exports = new Config(__filename)
  .withLocator(new GlobTestFileLocator("**/*.test.js"))
  .withParser(new SpecTestFileParse())
  .withRunner(new AsyncRunner())
  .withSetting("randomizeTests", true);

Write Tests

const assert = require("assert");

describe("beforeEach", () => {
  let baseValue;

  beforeEach(() => {
    baseValue = 10;
  });

  it("should sum with base value", async () => {
    assert.strictEqual(baseValue, 10);
  });

  describe("nesting", () => {
    beforeEach(() => {
      baseValue++;
    });

    it("should sum with incremented base value", async () => {
      assert.strictEqual(baseValue, 11);
    });
  });
});

Run

$ bespin

Packages

Addons

Development

Name

bespin is a working title and will change upon initial release.

Releases

No releases published

Packages

No packages published