Doctests for JavaScript (and CoffeeScript)
WTFPL License
Changes:
import.meta.resolve
to support relative and bare specifiers in import declarations (#177)Published by davidchambers 11 months ago
Changes:
--coffee
is now necessary to test CoffeeScript files (#152)doctest
now provides richer representations of test results (#164)--type js
is now assumed for files without extensions (#149)__filename
now refers to the source file rather than a temporary file (#165)acorn
dependency upgraded from 8.5.x
to 8.11.x
(#166)coffeescript
dependency upgraded from 1.12.x
to 2.7.x
(#153, #167)sanctuary-show
dependency upgraded from 2.0.x
to 3.0.x
(#168)sanctuary-type-classes
dependency upgraded from 12.1.x
to 13.0.x
(#169)Published by davidchambers almost 3 years ago
Changes:
acorn
dependency upgraded from 7.3.x
to 8.5.x
(#139)sanctuary-show
dependency upgraded from 1.0.x
to 2.0.x
(#140)sanctuary-type-classes
dependency upgraded from 10.0.x
to 12.1.x
(#141, #142, #143)Published by davidchambers about 3 years ago
Changes:
Published by davidchambers about 3 years ago
Published by davidchambers over 5 years ago
Changes:
Published by davidchambers over 5 years ago
Changes:
doctest
now returns a promise (#113)commander
dependency upgraded from 2.19.x
to 2.20.x
(#116)Published by davidchambers over 5 years ago
Changes:
```javascript
and ```
—may now be specified (#110)coffeescript
dependency upgraded from 1.10.x
to 1.12.x
(#103)commander
dependency upgraded from 2.8.x
to 2.19.x
(#104)sanctuary-type-classes
dependency upgraded from 9.0.x
to 10.0.x
(#105)Published by davidchambers over 6 years ago
Changes:
show
for string representations (#100)sanctuary-type-classes
dependency upgraded from 8.1.x
to 9.0.x
(#101, #102)Published by davidchambers over 6 years ago
Changes:
ramda
(#89)coffeescript
is now used in place of deprecated coffee-script
dependency (#92)esprima
dependency upgraded from 3.1.x
to 4.0.x
(#93)Published by davidchambers almost 7 years ago
This release improves webpack compatibility as a result of #83.
Sometimes usage examples must reference data constructors which are not in scope. These can be imported in the doctests themselves:
//. > var List = require('./test/internal/List')
//. > var Nil = List.Nil
//. > var Cons = List.Cons
//.
//. > reverse(Nil)
//. Nil
//.
//. > reverse(Cons(1, Cons(2, Cons(3, Nil))))
//. Cons(3, Cons(2, Cons(1, Nil)))
The above approach may not be optimal when using Transcribe, as the preamble will be included in the generated readme. To keep the readme clean, one may include doctest-specific imports in the source code itself, guarded to ensure they are ignored in other contexts:
if (typeof __doctest !== 'undefined') {
var List = require('./test/internal/List');
var Nil = List.Nil;
var Cons = List.Cons;
}
The above approach does not work well in conjunction with build tools such as webpack, which attempt to include guarded modules when generating a bundle. This is particularly problematic for those who depend on the package in question: test modules are not distributed, so ./test/internal/List
will not exist.
Fortunately, webpack can be tricked. This release introduces __doctest.require
, which is simply a reference to require
. The indirection is sufficient to throw webpack off the scent:
if (typeof __doctest !== 'undefined') {
var List = __doctest.require('./test/internal/List');
var Nil = List.Nil;
var Cons = List.Cons;
}
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago
Published by davidchambers almost 7 years ago