Skip to content

Instantly share code, notes, and snippets.

View tbadalov's full-sized avatar

Turkhan tbadalov

  • Baku, Azerbaijan
View GitHub Profile
@tbadalov
tbadalov / how_i_write_tests_for_node_and_the_browser.markdown
Created April 16, 2018 23:11
how I write tests for node and the browser

In node I use simple test libraries like tap or tape that let you run the test files directly. For code that needs to run in both the browser and node I use tape because tap doesn't run in the browser very well and the APIs are mostly interchangeable.

The simplest kind of test I might write in test/ looks like:

var test = require('tape');
var someModule = require('../');

test('fibwibblers and xyrscawlers', function (t) {
 t.plan(2);