Giter VIP home page Giter VIP logo

doc-tester's People

Contributors

mike-north avatar sparshithnr avatar stefanpenner avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

doc-tester's Issues

Add debugging/inspecting support

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

Add CI

I would recommend travis-ci linux, and ideally also windows.

A line that does not end with `;` causes some issues:

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 |     });

Only print TAP output to console if run through the CLI tool

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 >

Readme should describe how inline `imports` work

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?

document public API from library in readme

Once this API stabilizes, could this API be documented in the readme? That way:

  1. the library can dog-food itself more
  2. other folks can easily integrate programatically

Add support using existing assertions w/ typescript code snippets

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.