Skip to content

Commit 0d5860f

Browse files
SamVerschuerennovemberborn
authored andcommitted
Add StackBlitz examples for command line documentation
1 parent b237d33 commit 0d5860f

File tree

11 files changed

+104
-0
lines changed

11 files changed

+104
-0
lines changed

.xo-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
"rules": {
7777
"ava/no-identical-title": "off"
7878
}
79+
},
80+
{
81+
"files": "examples/**",
82+
"rules": {
83+
"ava/no-only-test": "off"
84+
}
7985
}
8086
]
8187
}

docs/05-command-line.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ When using `npm test`, you can pass positional arguments directly `npm test test
8080

8181
## Running tests with matching titles
8282

83+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/matching-titles?file=test.js&terminal=test&view=editor)
84+
8385
The `--match` flag allows you to run just the tests that have a matching title. This is achieved with simple wildcard patterns. Patterns are case insensitive. See [`matcher`](https://github.com/sindresorhus/matcher) for more details.
8486

8587
Match titles ending with `foo`:
@@ -154,6 +156,8 @@ test(function foo(t) {
154156

155157
## Running tests at specific line numbers
156158

159+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/specific-line-numbers?file=test.js&terminal=test&view=editor)
160+
157161
AVA lets you run tests exclusively by referring to their line numbers. Target a single line, a range of lines or both. You can select any line number of a test.
158162

159163
The format is a comma-separated list of `[X|Y-Z]` where `X`, `Y` and `Z` are integers between `1` and the last line number of the file.
@@ -236,6 +240,8 @@ Use the `--verbose` flag to enable the verbose reporter. This is always used in
236240

237241
### TAP reporter
238242

243+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/tap-reporter?file=test.js&terminal=test&view=editor)
244+
239245
AVA supports the TAP format and thus is compatible with [any TAP reporter](https://github.com/sindresorhus/awesome-tap#reporters). Use the `--tap` flag to enable TAP output.
240246

241247
```console

examples/matching-titles/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "ava-matching-titles",
3+
"description": "Example for running tests with matching titles",
4+
"scripts": {
5+
"test": "ava --match='*oo*'"
6+
},
7+
"devDependencies": {
8+
"ava": "^3.15.0"
9+
}
10+
}

examples/matching-titles/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Running tests with matching titles
2+
3+
> Example for [running tests with matching titles](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-with-matching-titles)
4+
5+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/matching-titles?file=test.js&terminal=test&view=editor)

examples/matching-titles/test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
const test = require('ava');
3+
4+
test('foo will run', t => {
5+
t.pass();
6+
});
7+
8+
test('moo will also run', t => {
9+
t.pass();
10+
});
11+
12+
test.only('boo will run but not exclusively', t => {
13+
t.pass();
14+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "ava-specific-line-numbers",
3+
"description": "Example for running tests at specific line numbers",
4+
"scripts": {
5+
"test": "ava test.js:5"
6+
},
7+
"devDependencies": {
8+
"ava": "^3.15.0"
9+
}
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Running tests at specific line numbers
2+
3+
> Example for [running tests at specific line numbers](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-at-specific-line-numbers)
4+
5+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/specific-line-numbers?file=test.js&terminal=test&view=editor)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
const test = require('ava');
3+
4+
test('unicorn', t => {
5+
t.pass();
6+
});
7+
8+
test('rainbow', t => {
9+
t.fail();
10+
});

examples/tap-reporter/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "ava-tap-reporter",
3+
"description": "Example for a custom TAP reporter",
4+
"scripts": {
5+
"test": "ava --tap | tap-nyan"
6+
},
7+
"devDependencies": {
8+
"ava": "^3.15.0",
9+
"tap-nyan": "^1.1.0"
10+
}
11+
}

examples/tap-reporter/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Running tests at specific line numbers
2+
3+
> Example for a [custom TAP reporter](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-at-specific-line-numbers)
4+
5+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/tap-reporter?file=test.js&terminal=test&view=editor)

0 commit comments

Comments
 (0)