@hidesigns/hidesigns-test
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

HiDESIGNS Test

HiDESIGNS Test

Test runner wrapper used at HiDESIGNS for bootstrapping test environments with JS testing frameworks such as Mocha, Jasmine, etc.

Features

  • use npm scripts
  • TypeScript
  • pass environment variables through to all steps
  • sync and async setup steps
  • test framework agnostic (use Mocha, Jasmine, Newman, something else)

Install/configure

Install with NPM

    npm install --save-dev @hidesigns/hidesigns-test

Create a test runner file with the steps used to run your tests.

    import testRunner from '@hidesigns/hidesigns-test';

    testRunner({
      // Environment variables are passed to all server setup steps, and to the test itself.
      env: {
        NODE_ENV: 'test',
        // PORT environment variable is special. Tests will not start until the server is open on this port.
        PORT: 1337,
        TEST_VAR: 'foo'
      },
      beforeTests() {
        console.log('Before test hook called');
      },
      afterTests() {
         console.log('After test hook called');
      },
      server: [
        // Transpile TypeScript to JS
        {
          cmd: 'npm run build',
          wait: true
        },
        // Start server in dev mode
        {
          cmd: 'npm run dev'
        }
      ],
      // Test command runs the Jasmine tests
      test: {
        cmd: 'jasmine dist/**/*.spec.integration.js'
      }
    })

Finally, you can call the test runner from your NPM script

Javascript:

    "scripts": {
      "test": "node ./test/test-runner.js"
    }

TypeScript:

    "scripts": {
      "test": "node-ts ./test/test-runner.ts"
    }

License

HiDESIGNS Test integration testing system. Copyright (C) 2018 株式会社ハイデザインズ

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Readme

Keywords

Package Sidebar

Install

npm i @hidesigns/hidesigns-test

Weekly Downloads

0

Version

1.0.10

License

GPL

Unpacked Size

17.5 kB

Total Files

8

Last publish

Collaborators

  • jp_tannerm