$ npm install boat
Note: If you plan on using the command-line utility, you should run
npm install boat -g instead.
You can check out some examples of Boat inside the
- Create a file to initiate your tests from (ie.
- Inside this newly created testing file, you need to initiate Boat and tell it where your test files are.
var boat = ;var status = boat; // returns false if any tests failed
- That's it. You can then run your code with something like
node test.jsand you are good to go.
The Boat command-line utility is very easy to use.
$ boat <path>
There is only one argument, the path to the config file. If it is empty it will assume it is
This is what an example config file looks like.
moduleexports =files: './tests/*.test.js';
The only thing that is required is
files. Everything else in your config file will be passed to
Writing tests is really easy. Here is a test from the basic example.
var test = test;var Calc = ;;
There are four
assert functions bundled with Boat.
This makes sure that things are equal.
var age = 35;; // true
This makes sure that the object is of a certain type.
var name = 'boat';; // true
This makes sure that the passed object is true.
var statement = true;; // true
This makes sure that the passed object is false.
var statement = false;; // true
If your project needs a bit more finesse, that can be arranged too. All you need to do is pass a second argument to
var boat = ;boat;
If you need to run some kind of setup script before your tests are run, you can pass the scripts path to
before and Boat will run them for you. If you need to pass options to your
before hook, just set
before as an
object with a
before:path: './tests/before.js'optionForBeforeScript: 'secretive'
If you need, Boat can help you run a cleanup script, just pass a path to
after. If you need to pass options to your
after hook, just set
after as an
object with a
after:path: './tests/after.js'optionForAfterScript: 'secretive'
If your test code is written in a language that needs to be compiled (ie. CoffeScript or ES2015), then you should pass the
compile option to
boat.run(). It works the same as
after where you can pass either a
string or an
compiler:path: 'babel/register'stage: 0
The default reporter used by Boat is
dot, however you pass a custom reporter if you would like. You can look in here to see all of the reporters included by default, but if you would like to use your own feel free.
Note: When passing your own reporter, Boat will check to see if there is a
/ in the name. If there is, it will check its own included reporters and if it does not find what the reporter there, it will just include the path combined with the current working directory. If there is no
/, then it will just pass the reporter argument straight to
reporter: './reporters/dot' // will result in the reporter "dot" that is included by default.reporter: './custom/awesomeness' // this will require the reporter from "./custom/awesomeness".reporter: 'awesome-reporter' // this will be directly passed to require("awesome-reporter").
If you would like, you can have Boat watch for changes in your files. You can do this in two ways:
watch: truewatch: truewatchFiles: './src/*.js'
Boat will watch for updates or creations of files in the specified
watchFiles is empty it will use the test files earlier specified.
Note: Boat can only watch for creations of files if you only specify the directory and not paths to file or wildcards.
All options that you pass to
boat.run() will be passed down to the reporter that is used. So, if your reporter accepts additional arguments, you can put them in here.
Features coming in future releases:
cli. You will be able to call Boat from the command line. watch. You will be able to have Boat watch for changes in your tests and continually run them.
Boat is licensed under the MIT license.