Coder Social home page Coder Social logo

eater's Introduction

Eater

npm version Build Status Coverage Status

logo

Eater is Ea sy t est runn er . Eater has one simple rule.

If test file outputs `stderr` message, the test failed.

#Features

  • Multi-process: All eater test files run as separate processes and eater does not launch too many processes more than CPU-core number.
  • Easy mock: An eater test does not affect the other tests, but mock object sometimes kills your test.
  • Happy async: eater aims is here to handle async test well. Each eater files will run in Node.js child_process, so the tests always should be async first. If your tests mix sync and async tests, you will have a headache to maintain the tests.

demo

How to use

1. Install

$ npm install eater -g

2. Write some tests

// test/sometest.js
const assert = require('assert');
assert(1 === 2); // always failure

Run

$ eater

image

eater --dir and --ext and --glob

eater searches JavaScript files under process.cwd()/test dir by default. If you want to change the dir, use --dir option.

$ eater --dir spec/

And if you changed test file extension, like .jsx/.es6/.test.js, you use --ext option.

$ eater --ext jsx

eater can find test files using glob pattern match. you use --glob option.

$ eater --glob **/__test/**/*.js

file

$ eater test/sometest.js test/foo.js test/bar.jd

If you are power-assert user

1. install power-assert and espower-loader

$ npm install eater -D
$ npm install power-assert espower-loader -D

2. enable power-assert

// script/enable-power-assert.js
require('espower-loader')({
    cwd: process.cwd(),
    pattern: 'test/**/*.js'
});

3. run tests with --require

$ eater --require ./script/enable-power-assert.js

power-assert

If you are babel(JSX) user

1. install babel-register or active-cache-babel-register

$ npm install eater -D
$ npm install babel-register -D

or

$ npm install eater -D
$ npm install active-cache-babel-register -D

Note: active-cache-babel-register improves babel transpilation performance.

2. enable babel

// script/enable-babel.js
require('babel-register')({ // or to use require('active-cache-babel-register')
  ignore: (file) => {
    if (file.match(/node_modules/)) return true;
    return false;
  }
});

3. run tests with --require

$ eater --require ./script/enable-babel.js

if you are power-assert and babel user:

1. install babel-preset-power-assert

$ npm install babel-preset-power-assert -D

2. write your .babelrc

{
  "presets": ["es2015", "babel-preset-power-assert"]
}

3. run tests with --require

$ eater --require ./script/enable-babel.js

Coverage

1. install nyc instead of istanbul

$ npm install nyc -D

2. run test with nyc

$ nyc eater

eater runner settings

eater reads the arguments from settings.

  • package.json
  • .eaterrc

package.json

{
  "name": "eaterDemo",
  "version": "1.0.0",
  "scripts": {
    "test": "eater"
  },
  "eater": {
    "dir": "test/core",
    "require": [
      "./enable-power-assert.js",
      "./enable-jsx.js"
    ]
  }
}

.eaterrc

.eaterrc is JSON5 format so you can write comment and trailing commas.

{
  dir: "test/core",
  require: [
    "./enable-power-assert.js",
    "./enable-jsx.js",
  ],
}

runner

If you would like to use test runner, eater has test function.

const calc = require('../foo/bar/calc');
const test = require('eater/runner').test;
const assert = require('assert');

test('give 2 arguments return sum', () => {
  const result = calc.sum(1, 2);
  assert(result === 3);
});

test('give 2 arguments return sum on async', () => {
  const result = calc.sumAsync(1, 2);
  result.then((value) => {
    assert(value === 3)
  });
});

Note that each subtests also run as separated processes, you don't have to care about sync/async stuff.

Use custom reporter

$ npm install eater-pacman-reporter
$ eater --reporter eater-pacman-reporter

pacman

Custom Reporters

Exclusive feature

The exclusivity feature allows you to run only the specified test code by adding // eater:only comment on top of your test code. Here's an example.

// eater:only
const test = require('eater/lib/runner').test;
const mustCall = require('must-call');
const assert = require('power-assert');

test('only is executed', () => {
  assert(true);
});

And if you need to exclude your test case, only function is helpful.

// eater:only
const only = require('eater/lib/runner').only;
const test = require('eater/lib/runner').test;
const mustCall = require('must-call');
const assert = require('power-assert');

test('this test should not execute', (_, fail) =>{
  fail('should not be executed');
});

only('only is executed', () => {
  assert(true);
});

eater's People

Contributors

yosuke-furukawa avatar renovate-bot avatar bouzuya avatar watilde avatar koichik avatar dependabot[bot] avatar twada avatar

Stargazers

Roman Vasilev avatar Haroldo de Oliveira Pinheiro avatar Roman Hossain Shaon avatar Illarion Koperski avatar M. Ganeko avatar Charlike Mike Reagent avatar hong-jen kao avatar Shinya Sugo avatar tomonari_takahashi avatar Yusuke Fukasawa avatar Kento TSUJI avatar yuriettys avatar RhincodonTypus avatar Eric Obodo avatar Hiroaki Imai avatar typoerr avatar Satoshi Takeda avatar yuuki avatar Siegfried Ehret avatar Ryoji Miyazato avatar hkawaida avatar Kei Takahashi avatar Hazumu Jo avatar shikato avatar Atsushi Araki avatar D3I avatar Shunya Shishido avatar hirashin avatar Kohei avatar shimon avatar syuilo avatar reoring avatar Yuki Kodama avatar Pine Mizune avatar Favi_ty avatar Jannis R avatar pocketberserker avatar Masato Nakamura avatar dueno avatar Keita Akutsu avatar D. C. Rockwell avatar James Edward Lewis II avatar Jozsef Suba avatar oreshinya avatar joe-re avatar supermanner avatar  avatar mactkg avatar mohayonao avatar Masashi Fujita avatar Hiroyuki Usui avatar mfks17 avatar Shin Suzuki avatar Cside avatar qsona avatar Taro Hanamura avatar Tetsuya Yoshida avatar wataru kikuchi avatar  avatar Takashi Fujita avatar kazuya kawaguchi avatar S. Suzuki avatar Ryutaro Yamada avatar Kiyoshi Nomo avatar Haruki Konishi avatar KUBOTA Shota avatar tsuyoshi wada avatar  avatar Yuki Akiyama avatar Yoshiya Hinosawa avatar Alexey Komarov avatar yudppp avatar mkwtys avatar azu avatar Kengo Nakajima avatar  avatar  avatar AMAGI / Jun Yuri avatar

Watchers

 avatar  avatar James Cloos avatar tomonari_takahashi avatar  avatar

eater's Issues

Investigate CI is flaky.

Sometimes CI is not green.

  1. warning eventemitter message
  2. coveralls is flaky

If we get any error on CI, we need to investigate here.

Add `id` on subtest cases.

eater does not restrict same test case name as follows.

test('foo', ()=>{});

test('foo', ()=>{});

But the result and test duration time is mixed.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • colo ^1.0.0
  • exists-sync 0.1.0
  • glob ^7.1.6
  • json5 ^2.1.2
  • minimist ^1.2.5
  • @babel/core 7.14.0
  • @babel/preset-env 7.14.1
  • @babel/register 7.13.16
  • core-js 3.15.2
  • coveralls 3.1.0
  • eater-tap-reporter 0.1.0
  • eslint 7.27.0
  • espower-loader 1.2.2
  • mock-require 3.0.3
  • must-call 1.0.0
  • npm-run-all 4.1.5
  • nyc 15.1.0
  • power-assert 1.6.1
travis
.travis.yml
  • node 8
  • node 10
  • node 12

  • Check this box to trigger a request for Renovate to run again on this repository

Gif files in readme are huge

The gifs have huge resolution in the README, almost crashed my chrome on the first visit.
They are currently downsized to 888x457 from 2664x1372 (the 1st) and from 2612x1272 (the 2nd).

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.