3.0.2 • Published 6 years ago

@springworks/test-harness v3.0.2

Weekly downloads
646
License
MIT
Repository
github
Last release
6 years ago

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');

  });

});
3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.5.7

7 years ago

1.5.6

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.13

8 years ago

1.3.12

8 years ago

1.3.11

8 years ago

1.3.10

8 years ago

1.3.9

8 years ago

1.3.8

8 years ago

1.3.7

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago