Skip to content

Middleware

Manual Config

Wallaby.js copies all files specified in the files and tests lists to its own cache. It instruments these files, runs compilers, preprocessors and the postprocessor, and serves all files from the cache. Required files are served to the sandbox from the wallaby.js web server.

However, sometimes you may want to just specify some file(s) or a folder that wallaby.js will serve ‘as is,’ without copying it to its local cache, or instrumenting or processing it. You may also configure other options of how these files are served, such as cookies, various HTTP headers and so on.

You may serve anything by specifying middleware function that takes 2 arguments: express application instance and express instance, and allows you to set and use any middleware.

module.exports = function () {
return {
files: [
'src/**/*.js'
],
tests: [
'test/**/*Spec.js'
],
// telling wallaby to serve jspm_packages project folder
// ‘as is’ from the wallaby.js web server
middleware: (app, express) => {
app.use('/jspm_packages',
express.static(
require('path').join(__dirname, 'jspm_packages')));
}
};
};