eastern

a minimal BDD framework for ESM Modules

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
eastern
202.0.16 years ago6 years agoMinified + gzip package size for eastern in KB

Readme

Eastern

Eastern

<img alt="Npm version" src="https://badge.fury.io/js/eastern.svg">
<img alt="Build Status" src="https://travis-ci.org/59naga/eastern.svg?branch=master">


a minimal & blazing fast BDD Framework for ESM Modules

Installation

npm install eastern eastern-cli --global
# or
yarn global add eastern eastern-cli

The eastern command defines global.it, global.describe. And find and run test.mjs / test/**/*.mjs.
eastern
# 
#   0 passing (5 ms)

API

it.setOptions / setOptions

it.setOptions({ concurrency: 1, timeout: 100 });

Specs of the same level are executed in parallel, and there is a possibility that hooks conflict. In that case, please set the concurrency of that level to 1 and execute it in series. using it.setOptions

it(title, context)

it("foo", () => {});

✓  foo (1 ms)

1 passing (7 ms)

it(title), it.skip(title)

it("foo");
it.skip("bar");

-  foo
-  bar

0 passing (6 ms)
2 pending

it.only

it("foo", () => {
  throw new Error("ignored");
});
it.only("bar", () => {});
it.only("bar", () => {});

-  foo
✓  bar (2 ms)
✓  bar (2 ms)

1 passing (8 ms)
1 pending

it.before

import delay from "delay";

it.before(() => {
  console.log("foo");
});

it.before(async () => {
  await delay(15);
  console.log("bar");
});

it.before(() => {
  console.log("baz");
});

it("beep", () => {});
it("beep", () => {});
it("beep", () => {});

foo
bar
baz
  ✓  beep (1 ms)
  ✓  beep (1 ms)
  ✓  beep (1 ms)

  3 passing (26 ms)

it.after

import delay from "delay";

it.after(() => {
  console.log("bar");
});

it.after(async () => {
  await delay(15);
  console.log("baz");
});

it.after(() => {
  console.log("beep");
});

it("foo", () => {});
it("foo", () => {});
it("foo", () => {});

✓  foo (1 ms)
✓  foo (2 ms)
✓  foo (2 ms)
bar
baz
beep

3 passing (27 ms)

it.beforeEach

it.setOptions({ concurrency: 1 });
it.beforeEach(async () => {
  await delay(5);
  console.log("foo");
});
it("bar", () => {});
it("bar", () => {});
it("bar", () => {});

foo
  ✓  bar (8 ms)
foo
  ✓  bar (7 ms)
foo
  ✓  bar (5 ms)

  3 passing (28 ms)

it.afterEach

import delay from "delay";

it.setOptions({ concurrency: 1 });
it.afterEach(async () => {
  await delay(5);
  console.log("bar");
});
it("foo", () => {});
it("foo", () => {});
it("foo", () => {});

bar
  ✓  foo (1 ms)
bar
  ✓  foo (0 ms)
bar
  ✓  foo (0 ms)

  3 passing (28 ms)

describe(title, fn(it, describe){})

describe(title), describe.skip(title)

import delay from "delay";

it.setOptions({ concurrency: 1 });
describe("1", it, describe) => {
  it.before(() => {
    console.log("  1-before");
  });
  it.beforeEach(() => {
    console.log("  1-beforeEach");
  });
  it.afterEach(() => {
    console.log("  1-afterEach");
  });
  it.after(() => {
    console.log("  1-after");
  });

  it("1-1");
  it.skip("1-2");
  it("1-notonly-1", () => {});
  it.only("1-only-1", async () => {
    await delay(5);
  });
  it.only("1-only-2", async () => {
    await delay(5);
  });

  describe("2");
  describe("3", it, describe) => {
    it.before(() => {
      console.log("      3-before");
    });
    it.beforeEach(() => {
      console.log("      3-beforeEach");
    });
    it.afterEach(() => {
      console.log("      3-afterEach");
    });
    it.after(() => {
      console.log("      3-after");
    });

    it("3-1");
    it.skip("3-2");
    it("3-notonly-1", () => {});
    it.only("3-only-1", async () => {
      await delay(5);
    });
    it.only("3-only-2", async () => {
      await delay(5);
    });

    describe("4");
    describe("5", it => {
      it("5");
    });
  });
});

1
1-before
  -  1-1
  -  1-2
  -  1-notonly-1
1-beforeEach
1-afterEach
  ✓  1-only-1 (7 ms)
1-beforeEach
1-afterEach
  ✓  1-only-2 (6 ms)
  -  2
  3
    3-before
    -  3-1
    -  3-2
    -  3-notonly-1
    3-beforeEach
    3-afterEach
    ✓  3-only-1 (7 ms)
    3-beforeEach
    3-afterEach
    ✓  3-only-2 (6 ms)
    -  4
    5
      -  5
    3-after
1-after

4 passing (39 ms)
9 pending

TEST FAILING

License

MIT