Skip to content

Instantly share code, notes, and snippets.

@toddself

toddself/test.js Secret

Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddself/1dd2876d120f86ab2871 to your computer and use it in GitHub Desktop.
Save toddself/1dd2876d120f86ab2871 to your computer and use it in GitHub Desktop.
var test = require('tape').test;
test('throwing', function(t){
t.throws(function(){
throw new Error('test');
}, 'threw');
t.end();
});
@toddself
Copy link
Author

13:29:01 ~/src/test
↳ node_modules/.bin/tape test.js
TAP version 13
# throwing
ok 1 threw

1..1
# tests 1
# pass  1

# ok

@toddself
Copy link
Author

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

test('throwing', function(t){
  t.throws(function(){
    throw new Error('test');
  }, /foo/, 'threw');

  t.end();
  });
13:32:07 ~/src/test
↳ node_modules/.bin/tape test.js
TAP version 13
# throwing
not ok 1 threw
  ---
    operator: throws
    expected: "/foo/"
    actual:   {"message":"test"}
    at: Test._cb (/Users/tkenned2/src/test/test.js:4:5)
  ...

1..1
# tests 1
# pass  0
# fail  1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment