# test-readme-md

> A tool that runs all JavaScript snippets in your README.md

Latest version **0.0.4** (published 2021-10-30) · GPL-3.0-only license · 0 weekly downloads

## Install

```sh
npm install test-readme-md
pnpm add test-readme-md
yarn add test-readme-md
bun add test-readme-md
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2021-10-30 |
| First published | 2021-06-02 |
| Weekly downloads | 0 |
| License | GPL-3.0-only |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 38.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Daubenschütz |
| Maintainers | timdaub |
| Keywords | test, readme, runner, quality assurance, match, code, markdown, language |

## Links

- npm: https://www.npmjs.com/package/test-readme-md
- npm.io page: https://npm.io/package/test-readme-md

## Dependencies (1)

- [inline-esm-worker](https://npm.io/package/inline-esm-worker.md) 0.0.4

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2021-10-30
- 0.0.3 — 2021-08-04
- 0.0.2 — 2021-06-07
- 0.0.1 — 2021-06-02

## README

# test-readme-md

> A tool that runs all JavaScript snippets in your README.md.

## Installation

```bash
$ npm i test-readme-md
```

## Usage

```js
import { testmd } from "test-readme-md";

const block = `
# this is a readme

This is some regular text that describes something.

Here's the first code block:

\`\`\`js
(() => true)();
\`\`\`

## Buggy code

The code in the next section will throw an error. \`testmd\` should throw too if
such error is bubbled up.

\`\`\`js
(() => { throw new Error("stop") })();
\`\`\`
`;

(async () => {
  testmd("js", block);
})();
```

An alternative way of using this module is by running the block parser
`matchBlocks` yourself and then running `exec` on each of them.

```js
import { matchBlocks, exec } from "test-readme-md";

const content = `
# this is a readme

This is some regular text that describes something.

Here's the first code block:

\`\`\`js
(() => true)();
\`\`\`

## Buggy code

The code in the next section will throw an error. \`testmd\` should throw too if
such error is bubbled up.

\`\`\`js
(() => { throw new Error("stop") })();
\`\`\`
`;

(async () => {
  const blocks = matchBlocks(content);
  for (let block of blocks) {
    await exec(block);
  }
})();
```

## Changelog

### 0.0.4

- Upgrade inline-esm-worker@0.0.4 to allow inline comments in worker code

### 0.0.3

- Expose `exec` function and document usage in `readme.md`

### 0.0.2

- Bump `inline-esm-worker` version to 0.0.3

### 0.0.1

- Initial release

## License

See LICENSE file.

---
_Source: https://npm.io/package/test-readme-md · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
