@cfware/fastify-test-helper

Testing helper for @cfware/ava-selenium-manager with fastify

Usage no npm install needed!

<script type="module">
  import cfwareFastifyTestHelper from 'https://cdn.skypack.dev/@cfware/fastify-test-helper';
</script>

README

@cfware/fastify-test-helper

Travis CI Greenkeeper badge NPM Version NPM Downloads MIT

Testing helper for @cfware/ava-selenium-manager with fastify

Install @cfware/fastify-test-helper

This module requires node.js 13.7.0 or above.

npm i -D @cfware/tap-selenium-manager @cfware/fastify-test-helper

Usage

import t from 'libtap';
import {testBrowser} from '@cfware/tap-selenium-manager';
import {FastifyTestHelper} from '@cfware/fastify-test-helper';

page('index.html', t => {
    // Test index.html here
});

testBrowser(t, 'firefox', new FastifyTestHelper(), {
  async 'index.html'(t, selenium) {
    // Test index.html here
  }
});

See tests in @cfware/history-state for a real life usage example.

new FastifyTestHelper(options)

  • options - optional settings specific to setup of the fastify daemon.

options.cwd

Sets the current working directory, default process.cwd().

options.nodeModulesPrefix

The base path to serve node_modules. Default /node_modules.

options.nodeModulesRoot

Sets the local directory to serve under options.nodeModulesPrefix. Default to node_modules under options.cwd.

options.testsPrefix

The base path which contains pages to be tested. Default /.

options.testsRoot

Points to files which should be served under options.testsPrefix. Default to fixtures under options.cwd.

options.customGetters

This object is used to register custom GET URL's to a local path.

Example:

{
    customGetters: {
        '/url.js': 'index.js'
    }
}

This will cause requests to the URL /url.js to serve index.js. The path of index.js is relative to process.cwd(), no attempt is made to prevent serving parent directories.

options.babelrc

Ignores any .babelrc and babel.config.js settings by default.

The following plugins are enabled by default:

The following parser plugins are enabled by default:

  • objectRestSpread
  • importMeta
  • classProperties

If options.babelrc is provided it replaces the default settings. Default options can be retrieved from the defaultBabelRC named export and merged using Object.assign or ES2018 object spread.