All Projects → juliangruber → Tape Run

juliangruber / Tape Run

Headless tape test runner

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tape Run

Zunit
A powerful testing framework for ZSH projects
Stars: ✭ 140 (-36.65%)
Mutual labels:  tap
Reflow
Content-routable socks5 proxy switcher for your entire LAN.
Stars: ✭ 170 (-23.08%)
Mutual labels:  tap
Tox
Command line driven CI frontend and development task automation tool.
Stars: ✭ 2,523 (+1041.63%)
Mutual labels:  travis
Industrial ci
Easy continuous integration repository for ROS repositories
Stars: ✭ 146 (-33.94%)
Mutual labels:  travis
Cistern
A terminal UI for Unix to monitor Continuous Integration pipelines from the command line. Current integrations include GitLab, Azure DevOps, Travis CI, AppVeyor and CircleCI.
Stars: ✭ 161 (-27.15%)
Mutual labels:  travis
Homebrew Terraforms
Homebrew repository for a Terraform version switcher and all Terraform versions
Stars: ✭ 174 (-21.27%)
Mutual labels:  tap
Ci Detector
Detect continuous integration environment and get information of current build
Stars: ✭ 138 (-37.56%)
Mutual labels:  travis
Gcr.io
🌀 sync the docker images of the gcr.io and quay.io
Stars: ✭ 200 (-9.5%)
Mutual labels:  travis
Crown
Based on SpringBoot2, Crown builds a rapidly developed web application scaffolding.
Stars: ✭ 161 (-27.15%)
Mutual labels:  travis
Env Ci
Get environment variables exposed by CI services
Stars: ✭ 180 (-18.55%)
Mutual labels:  travis
Angular1 Webpack Starter
Component based Angular(1.x) web development with Webpack and ES6.
Stars: ✭ 148 (-33.03%)
Mutual labels:  travis
Reactn
React, but with built-in global state management.
Stars: ✭ 1,906 (+762.44%)
Mutual labels:  travis
Testen
✔️ Run tests for multiple versions of Node.js in local env.
Stars: ✭ 176 (-20.36%)
Mutual labels:  travis
Use Force Update
React Hook to force your functional component to update.
Stars: ✭ 142 (-35.75%)
Mutual labels:  travis
Bats Core
Bash Automated Testing System
Stars: ✭ 2,820 (+1176.02%)
Mutual labels:  tap
Use Clippy
React Hook for reading from and writing to the user's clipboard.
Stars: ✭ 139 (-37.1%)
Mutual labels:  travis
Rabtap
RabbitMQ wire tap and swiss army knife
Stars: ✭ 171 (-22.62%)
Mutual labels:  tap
Docker Elastic
Deploy Elastic stack in a Docker Swarm cluster. Ship application logs and metrics using beats & GELF plugin to Elasticsearch
Stars: ✭ 202 (-8.6%)
Mutual labels:  travis
Lighthousebot
Run Lighthouse in CI, as a web service, using Docker. Pass/Fail GH pull requests.
Stars: ✭ 2,251 (+918.55%)
Mutual labels:  travis
Travis cpp tutorial
Tutorial how to use Travis CI with C++
Stars: ✭ 178 (-19.46%)
Mutual labels:  travis

tape-run

A tape test runner that runs your tests in a (headless) browser and returns 0/1 as exit code, so you can use it as your npm test script.

build status downloads

Usage

First write a test utilizing tape and save it to test/test.js:

var test = require('tape');

test('a test', function (t) {
  t.ok(true);
  t.end();
});

Then run this command using tape-run and browserify and watch the magic happen as the TAP results stream in from a browser (default: electron):

$ browserify test/*.js | tape-run
TAP version 13
# one
ok 1 true

1..1
# tests 1
# pass  1

# ok

$ echo $?
0

rollup

In simple cases you can run rollup and tape-run right from command line:

$ rollup test/test.js -f iife  | tape-run

If you want to use a configuration file, here's an example for rollup -c | tape-run:

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import builtins from 'rollup-plugin-node-builtins';
import istanbul from 'rollup-plugin-istanbul';

export default {
  input: 'test/test.js',
  output: { format: 'iife', sourcemap: 'inline' },
  plugins: [
    resolve(),
    commonjs(),
    builtins(),
    istanbul({ exclude: ['dist'] })
  ]
}

With webpack

To use with webpack, set up a webpack.test.config.js to bundle your tape tests. Then, include webpack-tape-run plugin in it. As a result, $ webpack --config webpack.test.config.js builds your tests with webpack, runs them in a headless browser, and outputs tap into console with correct exit code. Neat!

API

You can use tape-run from JavaScript too:

var run = require('tape-run');
var browserify = require('browserify');

browserify(__dirname + '/test/test.js')
  .bundle()
  .pipe(run())
  .on('results', console.log)
  .pipe(process.stdout);

And run it:

$ node example/api.js
TAP version 13
# one
ok 1 true

1..1
# tests 1
# pass  1

# ok
{ ok: true,
  asserts: [ { ok: true, number: 1, name: 'true' } ],
  pass: [ { ok: true, number: 1, name: 'true' } ],
  fail: [],
  errors: [],
  plan: { start: 1, end: 1 } }

run([opts])

opts can be:

  • wait (Number) [Default: 1000]: Make tap-finished wait longer for results. Increase this value if tests finish without all tests being run.
  • port (Number): If you specify a port it will wait for you to open a browser on http://localhost:<port> and tests will be run there.
  • static (String): Serve static files from this directory.
  • browser (String): Browser to use. Defaults to electron. Available if installed:
    • chrome
    • firefox
    • ie
    • phantom
    • safari
  • keepOpen (Boolean): Leave the browser open for debugging after running tests.
  • node (Boolean): Enable nodejs integration for electron.
  • basedir (String): Set this if you need to require node modules in node mode

The CLI takes the same arguments, plus --render (see blow):

$ tape-run --help
Pipe a browserify stream into this.
browserify [opts] [files] | tape-run [opts]

Options:
  --wait       Timeout for tap-finished                                                                                
  --port       Wait to be opened by a browser on that port                                                             
  --static     Serve static files from this directory                                                                  
  --browser    Browser to use. Always available: electron. Available if installed: chrome, firefox, ie, phantom, safari  [default: "electron"]
  --render     Command to pipe tap output to for custom rendering                                                      
  --keep-open  Leave the browser open for debugging after running tests                                                
  --node       Enable nodejs integration for electron                                                                  
  --basedir    Set this if you need to require node modules in node mode                                               
  --help       Print usage instructions  

...or any of the other options you can pass to browser-run.

Custom Rendering

In order to apply custom transformations to tap output without sacrificing the proper exit code, pass --render with a command like tap-spec:

$ browserify test.js | tape-run --render="tap-spec"

  one

    ✔ true

Headless testing

In environments without a screen, you can use Xvfb to simulate one. We recommend using the default electron browser, which however requires you to add additional parts to your headless configurations.

GitHub Actions

This is a full example to run npm test. Refer to the last 2 lines in the YAML config:

on:
  - pull_request
  - push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/[email protected]
    - run: npm install
    - run: sudo apt-get install xvfb
    - run: xvfb-run --auto-servernum npm test

Travis

Add this to your travis.yml:

addons:
  apt:
    packages:
      - xvfb
install:
  - export DISPLAY=':99.0'
  - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
  - npm install

Full example.

Any gnu/linux box

$ sudo apt-get install xvfb # or equivalent
$ export DISPLAY=':99.0'
$ Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
$ browser-run ...

Docker

There is also an example Docker image. Source

Installation

With npm do

$ npm install tape-run -g # for cli
$ npm install tape-run    # for api

Sponsors

This module is proudly supported by my Sponsors!

Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my Patreon. Not sure how much of my modules you're using? Try feross/thanks!

License

(MIT)

Copyright (c) 2013 Julian Gruber <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].