0.0.2 • Published 7 years ago
laat-readme-jest v0.0.2
readme-jest
WIP! use with caution
Execute code blocks with jest
Install
npm install -D laat-readme-jest
jest config
module.exports = {
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__" -->
import helloWorld from 'laat-readme-jest';
helloWorld(); // => 'hello-world'
throws
const a = () => {
throw new Error('MyError');
};
a(); // throws /MyError/
Promises
const b = Promise.resolve('foobar')
b; // Promise 'foobar'
const d = Promise.resolve('foobar')
d; // resolves to 'foobar'