laat-readme-jest

0.0.2 • Public • Published

readme-jest travis npm

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'

Readme

Keywords

none

Package Sidebar

Install

npm i laat-readme-jest

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • laat