Classy Test
![Build Status](https://travis-ci.org/vikeen/classy-test.svg?branch=master)
Opinionated class based testing framework.
Install
$ npm install classy-test
Usage
Command Line Interface
$ node node_modules/classy-test/bin/classy-test-cli.js
Exported Module
const ClassyTestRunner = require("classy-test");
new ClassyTestRunner().run();
API
ClassyTestRunner([options])
options
directories
Type: string[]
Default: ['test']
Relative paths to all directories that should be searched for test case files.
extension
Type: string
(test file extension)
Default: '.test.js'
Set the default file extension for your test files.
Examples
Component
my-project/lib/component.js
"use strict";
class SimpleComponent {
constructor(numbers) {
this.numbers = numbers;
}
sum() {
return this.numbers.reduce((a, b) => a + b);
}
sort() {
return this.numbers.sort();
}
}
module.exports = SimpleComponent;
Test File
my-project/test/component.test.js
"use strict";
const Component = require("../lib/component"),
classyTest = require("classy-test"),
assert = require("chai").assert;
class ComponentTestCase extends classyTest.BaseTestCase {
constructor() {
super();
}
testSum() {
assert.equal(new Component([1, 2, 3, 4]).sum(), 10);
}
testSort() {
assert.deepEqual(new Component([4, 1, 5, 2, 3]).sort(), [1, 2, 3, 4, 5]);
}
}
module.exports = [
ComponentTestCase
];
Output
$ node node_modules/classy-test/bin/classy-test-cli.js 1 ↵
debug: - 1 files found -
debug: /Users/johnrake/dev/classy-test-sandbox/test/component.test.js
debug: testing file - /Users/johnrake/dev/classy-test-sandbox/test/component.test.js
debug: found 1 test case(s)
debug: running test case [ComponentTestCase]
info: [ComponentTestCase] - 2 tests
..
info: ================================
info: pass: 2 -- fail: 0
info: ================================
time taken: 35.084ms
For more examples check here.
Team
![John Rake](http://gravatar.com/avatar/98008fcabb57bf00074774d37e2d79e7?s=144)
License
MIT © John Rake