Skip to content

This is the node.js version of the Edison .NET unit testing framework

License

Notifications You must be signed in to change notification settings

Badgerati/node-edison

Repository files navigation

Edison for Node.js (Alpha)

This is the Node.js version of Edison, if you're after the .NET version go here.

This is still in alpha, so use at own risk. Though from testing it's pretty reliable.

Features

  • Framework with Assert class for writing unit/integration tests.
  • Allows you to have setup/teardown for each test-file, as well as each test.
  • Can run tests async or sync.
  • CLI binary to run multiple test-files.
  • Able to have multiple test-cases for tests.
  • Set categories against tests to include/exclude specific ones during a full run.
  • Ability to store versioned console parameters in an Edisonfile.

Usage

See the examples/quick-start.test.js, and other files in examples, for usages.

Quick example:

var edison = require('../lib/edison.js').create();

edison.test('test-name', function(assert, done) {
    var x = 3;
    assert.areEqual(3, x); // will fail if x is not 3
    done(); // must be called at a point where the test will have succesfully ended
});

edison.run();

and to run:

node bin\edison examples\*.tests.js

or if you're using an Edisonfile, just:

node bin\edison

An example of the output in 'dot' format on the CLI is:

.......

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Total: 7, Passed: 7, Failed: 0, Errored: 0, Inconclusive: 0, Skipped: 0
Success Rate: 1.0
Failure Rate: 0.0
Duration: 0d 0h 0m 1s 19ms
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

where the fullstops at the top indicate tests that have passed. Failed tests will appear as either 'F' or 'E' (Failed or Errored). Any tests that fail will be displayed after all tests have run. If any tests have failed the process will return with an exit code of 1, otherwise 0 for success.

Edisonfile

The Edisonfile allows you to save, and version control, the arguments that you can supply to the binary. The file is of YAML format and should be saved at the root of your repository. The following is an example of the format:

test_files:
  - tests\*.tests.js

disable_console_output: true
console_output_type: dot
sync_type: async

To use, just run run the edison binary at the root, with no arguments supplied. The framework will locate the Edisonfile and populate the parameters accordingly.

For example, the above will be just like running:

node bin\edison tests\*.tests.js --dco --cot dot --st async

Bugs and Feature Requests

For any bugs you may find or features you wish to request, please create an issue in GitHub.

TODO

  • Write results to file
  • Send results to URL
  • Send results to Slack
  • Re-run failed tests
  • The 'tests' in Edisonfile should be to only run specific tests