1.0.0 • Published 5 years ago
bp-sanity-core v1.0.0
bp-sanity-core
Core entities for bp-sanity-tests.
Installation
$ npm i --save bp-sanity-core
Api
The package expose tow classes: Test
and TestRunner
Test
An abstract class that each test needs to drive from.
There is only one method on this class that needs to be override: runTest
.
This method contains the logic of the test, and it must return a promise:
- test passes: the method must return a resolved promise.
- test fails: the method must return a rejected promise or throw an exception.
TestRunner
A class responsible for running the test, it has only one method run()
.
The run()
method return a promise that resolves or rejects with the test result object looking like this:
failing: [{
description: "mock test that always fails",
testResult: "did not pass"
}],
passing: [{
description: "mock test that always pass",
testResult: "passing test"
}],
summary: "2 test run. 1 passed, 1 failed"
The promise will be resolved only when all the tests are passing (otherwise it will be rejected).
The following example may supply more information:
const tests = [new MockPassingTest(), new MockFailingTest()];
let testRunner = new TestRunner(tests);
let result = testRunner.run();
let expectedResult = {
failing: [{
description: "mock test that always fails",
testResult: "did not pass"
}],
passing: [{
description: "mock test that always pass",
testResult: "passing test"
}],
summary: "2 test run. 1 passed, 1 failed"
};
return expect(result).to.eventually.rejectedWith(expectedResult)
Contributing
Just fork this repo and open a pull request when your are ready.
Development capabilities:
Features:
- Testing framework (mocha + chai + mochawesome reporter)
- Linting (eslint)
- Documentation generation (jsdoc + loke-jsdoc-theme)
- Reports and code hosting (webserver)
Gulp tasks:
- default - Runs the default scripts. Currently doesn't run any scripts.
run by typing 'gulp'
- test - Runs the code testing script. Runs the tests inside the test folder.
run by typing 'gulp test'
- lint - Runs the code linting script. Lints the code inside the lib folder.
run by typing 'gulp lint'
- lint:fix - Runs the code linting fix script. Fixes linting errors within the lib folder.
run by typing 'gulp lint:fix'
- lint:fix-specific - Runs the code linting fix specific script. Fixes linting errors within a specific provided file.
run by typing 'gulp lint:fix-specific'
- generate:documentation - Runs the documentation generation script. Generated documentation based on jsdoc comments (in the lib folder) and additional documentation (int the docs folder).
run by typing 'gulp generate:documentation'
- serve - Runs the serve script. Serves all files within the package.
run by typing 'gulp serve'
- clean:reports - Runs the reports cleaning script. Cleans all reports within the package.
run by typing 'gulp clean:reports'
enjoy :)
1.0.0
6 years ago