laat-readme-jest
Execute code blocks with jest
Last updated 3 years ago by laat .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install laat-readme-jest 
SYNC missed versions from official npm registry.

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'

Current Tags

  • 0.0.2                                ...           latest (3 years ago)

2 Versions

  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 3
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |