Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

testling

tape-testing1.1kMIT/X111.7.7

write tests for browser code

test, browser, headless

readme

testling

Run testling-ci tests locally.

example

write a test:

var test = require('tape');

test('beep boop', function (t) {
    t.plan(2);
    t.equal(1+1, 2);
    t.ok(true);
});

run your test in a local headless browser:

$ browserify example/test.js | testling

TAP version 13
# beep boop
ok 1 should be equal
ok 2 (unnamed assert)

1..2
# tests 2
# pass  2

# ok

with an exit code of 0 for successes and non-zero for failures like a good unix citizen

Once you have a package.json with a configured "testling" field, you can just type:

$ testling

to run all your tests locally just like they will be run on testling-ci. This includes mocha harnesses, scripts, and files parameters.

usage

usage: testling {DIRECTORY|-} {OPTIONS}

If there (is no DIRECTORY and stdin is a tty) or the DIRECTORY is "-",
javascript will be read from stdin and executed.

Otherwise, DIRECTORY (or the $CWD) will be checked for a package.json with a
testling field.

OPTIONS are:

     --html  Instead of launching a server, show the generated html.

  --no-show  Don't render the console.log() output to the document body.

         -u  Instead of launching a browser, print the url to visit so you can
             open the browser yourself.

         -x  Launch a browser with an explicit command. By default, chrome or
             firefox is launched by searching your $PATH.

     --host  Set up the testling url on a specific hostname. Default: localhost

     --port  Set up the testling url on a specific port

testling field

Read more about how the package.json "testling" field works.

code coverage

To compute code coverage, just use the coverify transform with -t coverify when you run browserify.

coverify writes coverage data with console.log(), so you can pipe the output of testling through to the coverify command to parse the results and give human-readable output:

$ browserify -t coverify test.js | testling | coverify

TAP version 13
# beep boop
ok 1 should be equal

1..1
# tests 1
# pass  1

# ok

# /home/substack/projects/coverify/example/test.js: line 7, column 16-28

  if (err) deadCode();
           ^^^^^^^^^^^

# /home/substack/projects/coverify/example/foo.js: line 3, column 35-48

  if (i++ === 10 || (false && neverFires())) {
                              ^^^^^^^^^^^^

The exit code of coverify is non-zero when there are unreachable expressions.

dependencies

Make sure you have PhantomJS installed; this is the headless browser that testling will run your tests in if you are not using the -u option.

install

First, install browserify globally so that the testling command can find it when there is no browserify in ./node_modules/.bin:

npm install -g browserify

then do:

npm install -g testling

license

MIT

attack of the testlings!

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.7.7 - 2024-09-26

Commits

  • [Dev Deps] update auto-changelog, tape 33eca43
  • [Deps] update jsonify, object-inspect df687fd
  • [meta] Fix 404 url in package.json e777504

v1.7.6 - 2024-06-21

Commits

v1.7.5 - 2024-02-15

Commits

  • [Deps] update object-inspect, resolve, shell-quote eeba066
  • [Fix] render a &lt;br /&gt; instead of a newline, for IE < 8 e7b99cf
  • [Dev Deps] use ^ 74b1923
  • [Deps] update object-inspect, resolve 28ace20
  • [Dev Deps] update tape 6b716f2
  • [Dev Deps] update tape 50ee689
  • [Deps] update resolve a7ab4ee
  • [Dev Deps] update tape 8e2490e

v1.7.4 - 2022-09-22

Fixed

  • [Deps] switch win-spawn to cross-spawn #100
  • [Fix] avoid websocket prelude when --html #122

Commits

  • [meta] add auto-changelog 11e951e
  • [Refactor] elses should be cuddled c85152c
  • [meta] create FUNDING.yml; add funding in package.json b407a2f
  • [Dev Deps] update rimraf, safe-publish-latest, tape 32909bc
  • [Refactor] use [].concat for maybe-array 122d27b
  • [Deps] update concat-stream, object-inspect, optimist, resolve, shell-quote 12665da
  • [Deps] update @tapjs/tap-finished 2d288b5
  • [Deps] replace tap-finished with @tapjs/finished fc9795b
  • [meta] bump engines.node to v0.8, since through2 has never supported node v0.6 7819dac
  • [Deps] update browserify 9aee7b2
  • [Deps] update browser-launcher 33436d5

v1.7.3 - 2020-01-18

Commits

  • [meta] do not npmignore bundle dir 903f373
  • [Docs] testling_field.markdown: Added missing comma to browsers array 3315964

v1.7.2 - 2020-01-12

Fixed

  • [Fix] Keep track of browser process and manually kill #61 #71
  • [meta] remove nonexistent "main" #102
  • [New] add way to tell the browser to connect to a specific host and port. #78 #115

Commits

  • [meta] let npm reformat package.json 2443fad
  • [meta] update LICENSE so github can detect it 825a283
  • [Deps] update bouncy, browser-launcher, concat-stream, ecstatic, ent, glob, object-inspect, resolve, shallow-copy, shell-quote, tap-finished 5d932f0
  • [Refactor] add some missing semicolons 252c22d
  • [Refactor] remove unused variable b1aabde
  • [meta] gitignore node_modules and build output 953fdd1
  • [Fix] ensure proper spacing in error message 2d42973
  • [patch] Printing detected browsers and a few hints if no suitable browser is found ad85978
  • Only apps should have lockfiles 0630d9e
  • [meta] add safe-publish-latest 63fd18f
  • [readme] Add PhantomJS as a dependency d0383a7
  • Fix typo 1383142
  • [Dev Deps] update tape 72a1ff9
  • [meta] set npm save prefix 45e81fa
  • [Fix] remove bundledDependencies of browser-launcher, unneeded since 6a4ee9a5 af97334

v1.7.1 - 2014-09-20

Merged

  • Make testling CLI work on windows #98
  • Added a hint about browserify transformations to preprocess section #65

Commits

v1.7.0 - 2014-06-23

Commits

  • Implement preprocess 9491595
  • Preprocessing should not prevent other processing 22c3f31
  • Add additional pending operation when preprocessing 5da513d

v1.6.1 - 2014-03-08

Commits

  • don't depend on calling browser-launcher with -x 8cec97c

v1.6.0 - 2014-02-01

Commits

v1.5.9 - 2014-01-25

Commits

  • Unbreak testling -u on OS X 28e20eb

v1.5.8 - 2014-01-23

Commits

  • don't check headless on linux or bsd 85311db
  • be less annoying 4e7cc6f

v1.5.7 - 2013-12-27

Commits

v1.5.6 - 2013-12-22

Commits

  • allow the user to specify the test harness via argv 4b6a27d

v1.5.5 - 2013-12-10

Commits

v1.5.3 - 2013-10-11

Commits

  • Fix the --html option, when used in conjunction with "scripts". 9c8c1c9
  • Fix the 'scripts' option in package.json's "testling" section. 47d01f0

v1.5.2 - 2013-10-10

Commits

  • Fix the pkg.testling.html feature dacfc87

v1.5.1 - 2013-07-26

Commits

  • copy over the testling field info from testling-ci 9e1f497
  • section about the server field d515339
  • fix mocha by prefacing script paths with __testling b430365

v1.5.0 - 2013-07-26

Commits

  • --show/--no-show, documented toggling console.log() output 1ca55ef
  • parse the query params 100ef13
  • pipe output into a <pre> on the page 5546d06

v1.4.1 - 2013-07-26

Commits

  • finally works with websockets 1389bf9

v1.4.0 - 2013-07-26

Commits

  • use object-inspect in the prelude, expand %-args and use multi-arity console.log() params a35ff8c
  • using bouncy in front of the pkg.testling.server param b4b866a
  • put the sock and html under __testling to make room for custom servers b9e08ea
  • push the local browserify onto the /home/substack/prefix/bin:/home/substack/prefix/lib/gem/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games as a fallback if browserify isn't installed globally 6b3d240
  • forward upgraded headers along without connection: close f5dc564
  • host static files until __testling too fda6c6c

v1.3.3 - 2013-07-23

Commits

  • better error message for -x without an argument c03d01b

v1.3.2 - 2013-07-23

Commits

  • -x in favor of --bcmd 053e612
  • -x to launch a custom browser command c6ac15f
  • fix bug with -u in non-tty mode 586d8d1

v1.3.1 - 2013-07-22

Commits

  • make sure there are files after unglobbing 3da3dd9

v1.3.0 - 2013-07-21

Commits

v1.2.2 - 2013-07-03

Commits

v1.2.1 - 2013-06-24

Commits

  • why were these even checked into git e6ec958
  • usage info in the docs c83c3b8
  • upgrade browser-launcher e35b140
  • resolved, updated notes 253333c
  • Document that it requires a global browserify copy to work 06a1daf

v1.2.0 - 2013-06-19

Commits

  • add scripts from the scripts field c0a2bb5
  • fix for the html harness to insert the prelude 3a95e20

v1.1.1 - 2013-06-19

Commits

  • no more temporary output files 03d9056

v1.1.0 - 2013-06-19

Commits

v1.0.0 - 2013-04-23

Commits

  • bundle browser-launcher to get the path.exists -> fs.exists fix 278fa78
  • remove old stuff d476a5e
  • working pipable version 08866f2
  • forgot to check in cmd 3f4e48c
  • update the readme to run local tests d542b27
  • update deps 6887d00
  • fix path.exists ce34401
  • dev dep for the example 06510d9

v0.2.5 - 2012-07-01

Commits

v0.2.4 - 2012-06-30

Commits

  • node harness with t.log() and stubbed out t.createWindow() 0307525

v0.2.3 - 2012-06-30

Commits

v0.2.2 - 2012-06-30

Commits

v0.2.1 - 2012-06-30

Commits

v0.2.0 - 2012-06-29

Commits

  • redux d5a9367
  • factored out push() for pluggable output b125277
  • basic stub test works emitting json events 6c78e60
  • list remote browsers in a new cli 7b81b93
  • basic json example now works 649253a
  • account creation works f6f25e1
  • render browser output back to the terminal 11b72c1
  • catch errors in createWindow callbacks f689b08
  • beginnings of user auth verification fe3dc93
  • injection proxy works df888ca
  • split up server creating code into lib/servers, stubbed out tunnels a974a94
  • shim out testling visitor e047391
  • submitForm now works 1441297
  • fix option for headless and kill 5097134
  • t.log and t.createWindow work 9f938e0
  • integrated tunnels 0007c18
  • getting json output with tap harness in the browser 1583149
  • stack traces with truncated output f287e0d
  • testling auth/visit f6f4b35
  • factored out createWindow() logic, broke submitForm() somehow 04c8aae
  • tunnels and remote testling browsers work! 6d84224
  • documented usage 1b1e241
  • submitForm() works again with refactored createWindow() bf693b2
  • now integrated with browser-launcher 2fc0f0e
  • updated the docs a2d2de6
  • launch the browser automatically and headlessly 5dadf39
  • get a list of the remote browsers be64c3f
  • list local 12143d4
  • now with jquery a6de2c8
  • fix for output race condition cdf7efb
  • and a package.json b035ba3
  • render the bundle inline instead of relying on static/, now works with test file arguments 4a636db
  • example interaction 7002aef
  • testling params 8f1ee27
  • pipe tap to the console cc268b3
  • jsdom randomly won't set the title, whatever 8c4a654
  • problems with jsdom d9b92ff
  • better error reporting, use my jsdom with the default console.log() taken out abcd0b3
  • /visit stuff works with local testling-server 1788953
  • update example for schoolbus, delete lib/launcher.js 1adc4b4
  • forgot to add the producer 9d57cd8
  • --browsers now works with accounts! d1206ec
  • support --main and symlinks d4707f9
  • handle logs b372b6a
  • basic thing works for node 0b7050b
  • show source snippets from the failing assertions 51163d0
  • briefly document the api 4dec110
  • echo browser 7f3dbe9
  • auth works but doesn't tunnel e01c5d3
  • fix logs and close the document 4645525
  • remote testling browsers work! 542d68c
  • remove horizontal whitespace e12417b
  • installation note b0998e5
  • readme stub 1cc80b7
  • move the makefile into the scripts.install 1d4de7b
  • fix to set the window title 44867f3
  • log lines with >> 798b5c9
  • fixed the form example by adding stub content 27fbc14
  • turn on kill for headless mode, remove kill arg 43a866c
  • using noProxy, now works with firefox 5c8c2fc
  • pix a6dfefa