Skip to content

Commit

Permalink
docs: supertape: options
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Mar 1, 2024
1 parent 6433719 commit 272dd78
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 78 deletions.
70 changes: 29 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@

For a list of all built-in assertions, see [Operators](#operators).

## How 📼**Supertape** test looks like?

You can use both **CommonJS** and **ESM**, here is **ESM** example:

```js
import {test} from 'supertape';

const sump = (a, b) => a + b;

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```
## Install

```
Expand All @@ -60,7 +77,7 @@ Options

## Environment variables

- `SUPERTAPE_TIMEOUT` - timeout for long running processes;
- `SUPERTAPE_TIMEOUT` - timeout for long running processes, defaults to `3000` (3 seconds);
- `SUPERTAPE_CHECK_DUPLICATES` - toggle check duplicates;
- `SUPERTAPE_CHECK_SCOPES` - check that test message has a scope: `scope: subject`;
- `SUPERTAPE_CHECK_ASSERTIONS_COUNT` - check that assertion count is no more then 1;
Expand Down Expand Up @@ -292,55 +309,26 @@ There is a list of built-int `formatters` to customize output:

## API

### Methods
### test(message: string, fn: (t: Test) => void, options?: TestOptions)

The assertion methods of 📼**Supertape** are heavily influenced by [**tape**](https://github.com/substack/tape).

```js
const test = require('supertape');
const {sum} = require('./calc.js');

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```

or in `ESM`:

```js
import {test} from 'supertape';
import {sum} from './calc.js';

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```
Create a new test with `message` string.
`fn(t)` fires with the new test object `t` once all preceding tests have
finished. Tests execute serially.

## test(name, cb)
Here is Possible `options` similar to [Environment Variables](#environment-variables) but relates to one test:

Create a new test with `name` string.
`cb(t)` fires with the new test object `t` once all preceding tests have
finished. Tests execute serially.
- `checkDuplicates`;
- `checkScopes`;-
- `checkAssertionsCount`;
- `timeout`;

## test.only(name, cb)
### test.only(message, fn, options?)

Like `test(name, cb)` except if you use `.only` this is the only test case
that will run for the entire process, all other test cases using `tape` will
be ignored.

## test.skip(name, cb)

Generate a new test that will be skipped over.

## test.extend(extensions)
### test.skip(message, fn, options?)

Extend base assertions with more:

Expand Down
60 changes: 23 additions & 37 deletions packages/supertape/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@

For a list of all built-in assertions, see [Operators](#operators).

## How 📼**Supertape** test looks like?

You can use both **CommonJS** and **ESM**, here is **ESM** example:

```js
import {test} from 'supertape';

const sump = (a, b) => a + b;

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```

## Install

```
Expand All @@ -61,7 +79,7 @@ Options

## Environment variables

- `SUPERTAPE_TIMEOUT` - timeout for long running processes;
- `SUPERTAPE_TIMEOUT` - timeout for long running processes, defaults to `3000` (3 seconds);
- `SUPERTAPE_CHECK_DUPLICATES` - toggle check duplicates;
- `SUPERTAPE_CHECK_SCOPES` - check that test message has a scope: `scope: subject`;
- `SUPERTAPE_CHECK_ASSERTIONS_COUNT` - check that assertion count is no more then 1;
Expand Down Expand Up @@ -179,39 +197,7 @@ There is a list of built-int `formatters` to customize output:

## API

### Methods

The assertion methods in `supertape` are heavily influenced by [tape](https://github.com/substack/tape).

```js
const test = require('supertape');
const {sum} = require('./calc.js');

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```

or in `ESM`:

```js
import {test} from 'supertape';
import {sum} from './calc.js';

test('calc: sum', (t) => {
const result = sum(1, 2);
const expected = 3;

t.equal(result, expected);
t.end();
});
```

## test(message: string, fn: (t: Test) => void, options?: TestOptions)
### test(message: string, fn: (t: Test) => void, options?: TestOptions)

Create a new test with `message` string.
`fn(t)` fires with the new test object `t` once all preceding tests have
Expand All @@ -224,17 +210,17 @@ Here is Possible `options` similar to [Environment Variables](#environment-varia
- `checkAssertionsCount`;
- `timeout`;

## test.only(message, fn, options?)
### test.only(message, fn, options?)

Like `test(name, cb)` except if you use `.only` this is the only test case
that will run for the entire process, all other test cases using `tape` will
be ignored.

## test.skip(message, fn, options?)
### test.skip(message, fn, options?)

Generate a new test that will be skipped over.

## test.extend(extensions)
### test.extend(extensions)

Extend base assertions with more:

Expand Down

0 comments on commit 272dd78

Please sign in to comment.