sparshithnr / doc-tester Goto Github PK
View Code? Open in Web Editor NEWTest your markdown file code samples.
Test your markdown file code samples.
Given this slightly modified example from the readme (debugger
inserted).
import {
subtract
} from './add';
const numbers = {
a: 4,
b: 3
};
debugger;
subtract(numbers.a, numbers.b) // equals: 1;
add( {
a: 4
}.a, 4) // equals: 8;
I would expect (or similar):
./bin/doc-test --inspect -f README.md
./bin/doc-test --inspect-brk -f README.md
To break within the executed tests, and be debuggable from chromes about:inspect
I would recommend travis-ci linux, and ideally also windows.
A small modification to the example in the readme reveals new lines are ignored:
import {
subtract
} from './add';
const numbers = {
a: 4,
b: 3
};
console.log('hello')
subtract(numbers.a, numbers.b) // equals: 1;
add( {
a: 4
}.a, 4) // equals: 8;
Specifically I added a console.log(
without a trailing ;
(which is valid JS)
Result:
node ./bin/doc-test -f ./README.md (127)
Not all tests passed:
SyntaxError: unknown: Unexpected token, expected "," (12:59)
10 | assert.notEqual(add(4, 5), 6);
11 | assert.throws(() => { throw add(2, 3) }, 'Throws error');
> 12 | const numbers = { a: 4, b: 3};assert.equal(console.log(1)subtract(numbers.a, numbers.b), 1);
| ^
13 | assert.equal(add( { a: 4}.a, 4), 8);
14 | ;assert.expect(5);
15 | });
Please add to the README: a list (and examples) of the special comments we can use in code blocks
4; // equal: 4
This is the output I'm seeing from the documentation tool
๐ฆ pkg-js-single-file
TAP version 13
ok 1 test > 3 + 4
1..1
# pass 1
# skip 0
# todo 0
# fail 0
โ
SECRET_STRING
I'm going to be invoking runTests
many times (each file has many symbols, and each symbol can have many doctest blocks) and would like to avoid extra stuff being logged to the console
This is what I'm looking for:
๐ฆ pkg-js-single-file
โ
foo
โ
bar
โ baz
< some data on expected vs. encountered values >
Specifically, they should explain that they abide by the node resolution algorithm, based on the doc file they are written in.
On that note, should we provide the accurate __dirname
and __filename
variables to these test files?
Once this API stabilizes, could this API be documented in the readme? That way:
It should be relatively easy to handle this by installing the appropriate babel 7 plugins. I think it's just
{
"presets": [
"@babel/env",
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
At which point this test case
```ts
function add(a: number, b: number) { return a + b; }
add(3, 4); // equals: 7
```
should work just as easily as your JS examples. You may need to write the code w/ tests to a file instead of evaluating it as a string, in order to make @babel/preset-typescript
happy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.