Skip to content

Commit

Permalink
Rewrite (#42)
Browse files Browse the repository at this point in the history
**New Features**
* Supports TypeScript out of the box
* Supports `import` syntax out of the box
* Better assert failure messages
* Stack traces point to the line in readme with the failing assert
* exits with code 1 when no tests found

**BREAKING CHANGES**
* Dropped support for Node < 8
* Code blocks must be tagged with `test`, see readme for examples.
  To get the old behavior add `--auto` argument
* Does not read babelrc file by default. Add `--babel` flag to enable it.
  • Loading branch information
laat authored Jun 11, 2019
1 parent fba9f44 commit 81e9a16
Show file tree
Hide file tree
Showing 69 changed files with 15,819 additions and 1,813 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: node_js
before_script:
- "npm run lint"
node_js:
- "10"
- "8"
7 changes: 0 additions & 7 deletions cli.js

This file was deleted.

1 change: 1 addition & 0 deletions examples/auto-discover-tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = num => Math.pow(num, 2);
13 changes: 13 additions & 0 deletions examples/auto-discover-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"name": "@laat/auto",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "readme-assert --auto"
},
"devDependencies": {
"readme-assert": "^5.0.6"
}
}
37 changes: 37 additions & 0 deletions examples/auto-discover-tests/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# auto discover test blocks

The default behavior is to detect code blocks tagged with `test`:

````
```js test
1 + 1 // => 1
```
````

We can also try to infer the tests to run with the `--auto` flag, which tries tries to find magic comments `//=>` in the documentation.

````
```js
1 + 1 // => 1
```
````

### Command

```
readme-assert --auto
```

````
```js
const pow2 = require("@laat/auto");
pow2(2); //=> 4
pow2(4); //=> 16
```
````

```js
const pow2 = require("@laat/auto");
pow2(2); //=> 4
pow2(4); //=> 16
```
Loading

0 comments on commit 81e9a16

Please sign in to comment.