Testing your API with Wallaby

Wallaby.js is a popular developer productivity tool that runs your JavaScript and TypeScript tests immediately as you type, highlighting results in your IDE right next to your code.

Wallaby, after installing and configuring per its setup instructions, works quickly with the RedwoodJS web side to help run tests for pages, components, and layouts.

However, to use Wallaby on the api side to help test services, directives, functions, webhooks or custom libraries, a little extra configuration is needed.

To enable Wallaby.js in the RedwoodJS api side, you need to update your applications’s api/jest.config.js.

You will want to add:

// For Wallaby Support 
if (process.env.DEBUG?.includes('wallaby')) config.runner = 'jest-runner'

Here is a full example api/jest.config.js file:

// api/jest.config.js 
// More info at https://redwoodjs.com/docs/project-configuration-dev-test-build const config = { rootDir: '../', preset: '@redwoodjs/testing/config/jest/api', }
 // For Wallaby Support 
if (process.env.DEBUG?.includes('wallaby')) config.runner = 'jest-runner' module.exports = config