Skip to content

hasundue/bddoc.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bddoc.js

A TypeScript/JavaScript library to generate markdown documentation from test codes in BDD style.

Warning

Alpha version. Not tested extensively yet. APIs may change frequently.

Usage

Deno

deno add jsr:@chiezo/bddoc

APIs

Note

This section is generated with bddoc itself from transform_test.ts and parse_test.ts.

import { parse, transform } from "@chiezo/bddoc";

transform

Transform tests to documentation:

assertEquals(
  transform(
    await Deno.readTextFile("./fixtures/input.ts"),
  ),
  await Deno.readTextFile("./fixtures/output.md"),
);

parse

Parse describe and it from tests:

const describes = parse(
  await Deno.readTextFile("./fixtures/input.ts"),
);
assertObjectMatch(describes[0], {
  target: "foo",
  its: [
    {
      behavior: "should do something",
      code: 'assertEquals("foo", "foo");',
    },
  ],
});
assertObjectMatch(describes[1], {
  target: "bar",
  its: [
    {
      behavior: "should do something else",
      code: `assertEquals("bar", "bar");`,
    },
    {
      behavior: "should not do something more",
      code: `assertNotEquals("bar", "baz");`,
    },
  ],
});

Todo

  • Runtimes
    • Browsers
    • Bun
    • Deno
    • Node.js
  • Test Interfaces
    • Deno.test
    • describe it
  • Assertion Interfaces
    • @std/assert
    • expect
  • Backend
    • Built-in (rule-based)
    • LLM (?)