readme-jest
WIP! use with caution
Execute code blocks with jest
Install
npm install -D laat-readme-jest
jest config
moduleexports = transform: 'readme.md': 'laat-readme-jest' '^.+\\.jsx?$': 'babel-jest' testMatch: '**/readme.md' '**/__tests__/**/*.js?(x)' '**/?(*.)(spec|test).js?(x)' moduleFileExtensions: 'md' 'js' ;
basic
true; // => true
import from package main
// To override main to import use the magic comment in markdown// <!-- test-main: "./__test__" --> ;; // => 'hello-world'
throws
const a = { throw 'MyError';};; // throws /MyError/
Promises
const b = Promiseb; // Promise 'foobar'
const d = Promised; // resolves to 'foobar'