This package has been deprecated

Author message:

Don't use @springworks/test-harness

@springworks/test-harness

3.0.2 • Public • Published

NPM Version Build Status Coverage Status Dependencies Dev Dependencies Greenkeeper badge

test-harness

Setup should and sinon with plugins.

Install

$ npm i -D @springworks/test-harness

Usage

Test-harness

Require @springworks/test-harness using the --require option when running tests with mocha.

$ mocha --require @springworks/test-harness

The --require option can be added to a mocha.opts file.

Example mocha.opts file:

--ui bdd
--check-leaks
--recursive
--slow 200
--reporter spec
--compilers js:babel/register
--require @springworks/test-harness

Commonly used random identifiers

Require @springworks/test-harness/test-data-helper and call the functions as needed. These have TypeScript definitions.

Example test file

No need to require should, sinon or any of the plugins.

const autorestoredSandbox = require('@springworks/test-harness/autorestored-sandbox');
const api_tester = require('@springworks/test-harness/api-tester');

describe('test-harness', () => {

  const sandbox = autorestoredSandbox();

  describe('globals', () => {

    it('should expose should as a global', () => {
      should.exist(should);
    });

    it('should expose sinon as a global', () => {
      should.exist(sinon);
    });

  });

  describe('asserting sinon fakes', () => {

    it('should use the should-sinon plugin', () => {
      const test_stub = sinon.stub().returns('hello');
      test_stub().should.eql('hello');
      test_stub.should.have.callCount(1);
    });

  });

  describe('asserting promises', () => {

    it('should use the should-promised plugin', () => {
      return Promise.resolve().should.be.fulfilled();
    });

  });

  describe('asserting http requests', () => {

    it('should use the should-http plugin', () => {
      ({ statusCode: 200 }).should.have.status(200);
    });

  });

  describe('run tests against static API', () => {

    api_tester.configureStaticApi(data_store_api_static.createApiServer, config.get('test_helper.data_store_api.port'));

    it('should be able to send request to static API and resolve without issues');

  });

});

Readme

Keywords

none

Package Sidebar

Install

npm i @springworks/test-harness

Weekly Downloads

19

Version

3.0.2

License

MIT

Unpacked Size

19.5 kB

Total Files

18

Last publish

Collaborators

  • springworksdev
  • springworksprime