@cfware/fastify-test-helper
v1.0.0
Published
Testing helper for @cfware/tap-selenium-manager with fastify
Downloads
27
Readme
@cfware/fastify-test-helper
Testing helper for @cfware/tap-selenium-manager with fastify
Usage
import t from 'libtap';
import {testBrowser} from '@cfware/tap-selenium-manager';
import {FastifyTestHelper} from '@cfware/fastify-test-helper';
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:
- babel-plugin-remove-ungap
- babel-plugin-bare-import-rewrite
- babel-plugin-istanbul
- @babel/plugin-proposal-optional-chaining (loose mode)
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.