Skip to content

Instantly share code, notes, and snippets.

@meisl meisl/my-test1.js
Last active Dec 10, 2015

What would you like to do?
"just run my buster tests on `npm test`!" - "run-tests" should be in your project folder, as should "package.json". - "my-test1.js" assumed under test/ in your project folder
var buster = require("buster"); // on Windows you may need require("buster-node"); instead
var assert = buster.assert;
var refute = buster.refute;
buster.testCase("test case 1", {
setUp: function() {
// things to prepare before each test
tearDown: function() {
// things to clean up after each test
"a passing test": function() {
assert.equals(1, 1);
"a failing test": function() {
"an async test, callback will be called eventually": function(testDone) {
var cp = require("child_process");
cp.exec("echo foo", function(err, stdout, stderr) {
assert(true); // your assertions here. with assert(true) we simply confirm that the callback was indeed called
testDone(); // MUST call this to tell buster that we're finally done with the test
"an async test, error from child_process.exec should be re-thrown": function(testDone) {
var cp = require("child_process");
var fnUnderTest = function(cmd) {
cp.exec(cmd, function(err, stdout, stderr) {
if (err)
throw err;
// Now HOW do I assert that a "No-such-command" is thrown eventually?
scripts: {
"test": "node ./run-tests"
#!/usr/bin/env node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.