Skip to content

robdmoore/Approvals.NodeJS

 
 

Repository files navigation

Approvals

Approval Tests Library - Capturing Human Intelligence

Learn more more about Approvals at approvaltests.com

Latest Builds

Service Status
Linux (Travis CI) Build Status
Windows (AppVeyor) Build status
Coverage (Coveralls) Coverage Status

Invoke via:

Getting Started

Below is a simple getting started using Mocha. We now support Jasmine as well, just replace mocha with Jasmine below and you should be able to get started.

  1. Create a project (folder)
mkdir MyProject
cd MyProject`
  1. Install approvals npm install --save-dev approvals

  2. Install Mocha globally to execute our tests

npm install -g mocha  
  1. Create a sample Mocha test file called test.js.
require('approvals')
  .configure(/* options - see below */)
  .mocha(__dirname);

describe('When running some tests', function () {
  it('should be able to use Approvals', function () {
    var data = "Hello World!";
    this.verify(data);  // or this.verifyAsJSON(data)
  });
});
  1. Test the file with mocha.
mocha test.js
  1. You should be presented with a diff tool. (if not, you may need to install one)

Documentation

Approvals Github Wiki!

Usage

Config (override)

The default configuration can be overriden by using the .configure(...) as shown below.

require('approvals')
  .configure({
    reporters:  ["p4merge", "opendiff", "tortoisemerge", "gitdiff"],
    appendEOL: false, // default is (still up for discussion, but currently true on windows false everywhere else
    EOL:  require('os').EOL,
    errorOnStaleApprovedFiles: true,
  }).mocha(__dirname); // or .jasmine(__dirname);
/* ... */

Approved File Artifacts

The *.approved.* files must be checked into source your source control. This can be an issue with git as it will change the line endings. The suggested fix is to add *.approved.* binary to your .gitattributes

Others?

Contributing

Check out the guidlines!

License

Copyright (c) 2012-2014 Llewellyn Falco, Jason Jarrett
Licensed under the Apache license.

About

Approval Tests implementation in NodeJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.6%
  • Shell 0.4%