UltimateTests
Provides flexible tests environment.
To use babel just create file .babelrc in project root and install needed dependencies.
Usage example:
File: test.js
const Tests = ; /* --------------------------------- Tests --------------------------------- */ testsDir: './tests' // default './' // default config for each testBlock // each testBlock can override this ( see below ) defaultConfig: // defines which tests to run testIndexes: /* see below */ logs: // 0 - only system messages ( default ) // 1 - system + info messages // 2 - all messages // 3 - print all hidden properties in objects level: 0 // advanced systemMessages: /* see test-block.js */ tests: TestsBlock1: file: 'tests-block-1' testIndexes: only: 123 // which tests will be executed by index except: // which tests will be omitted by index ;
File: ./tests/tests-block-1.js
/** * Module must return function * @param (Function) assert( condition, errorMsg ) - is used to check test results * @param (Function) log( ...msg ) - is used to print some data * @param (Function) error( msg ) - is used to immediately throw error */module // Array of all tests ( required ) tests: /* ------------ 1 ------------- */ { // ... some test body ... // this.tests[ testIndex ]; // current test this; ; // prints message if log.level >= 2 ; ; // throws error if a !== b if ax !== bx ; // throws error return Promise; // if test might return Promise } {};