The preprocessor function may take one or two arguments (making it sync or async):

'**/*.js':file=>file.content+'// modified'

'**/*.js':(file,done)=>done(file.content+'// modified')

In case of one argument the preprocessor result is expected immediately. In case of two arguments the preprocessor is async and the second argument is the callback that is invoked when the preprocessor result is ready.

The first argument is a file object.

The file.content property contains the current content of the file.

The file.path property contains the current path to the file.

The file.rename(newPath) function allows you to rename/move the file.

The file.changeExt(newExt) function is just a shortcut for the rename function allowing you to change the file extension. For example, file.changeExt('js') will change the file extension from whatever it is to .js.

For example, the following preprocessor runs a react tools transformation to all jsx files and renames them to *.jsx.js files.

an object: with code and map (or sourceMap) properties, where code is the file modified content and map is the source map of the transformation.

an error: error object of Error type (passed to done callback or thrown from sync preprocessor).

Please note that if the transformation produces a JavaScript file that you are interested to see the coverage for, then returning the source map is essential. Otherwise, the reported coverage and error stacks may not be correct.

Writing a custom preprocessor

If your preprocessor is more complex than a simple inline function, you may want to consider creating a separate module and also publishing it. Have a look at wallaby-ng-html2js-preprocessor for an example.