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
Hi,
there seem to be some issues with using wallaby and redwood.
I am using prisma generators like prisma-erm-generator. It seems wallaby cannot use it properly. Error: spawn prisma-dbml-generator ENOENT
The wallaby team tried to support me on it, but so far I wasn´t lucky to get it running. They also pointed out some inconsistencies on the redwood site, so I think it is worth investigating for the redwood team:
Here is the quote of their reply:
There were a couple of separate issues affecting your project:
Redwood spawns processes and relies on npm behaviour that sets process.env.PATH variable to include your local ./node_modules/.bin folder. Wallaby was not previously doing this. We’ve updated Wallaby to have the same behaviour but this issue could have been addressed with a configuration file.
Redwood has some unusual jest configuration where multiple projects reference the same rootDir explicitly. This caused Wallaby to incorrectly use your api environment variables for web tests.
module.exports = ({
autoDetect: true,
// The following is required to work around memory leak in redwood API tests:
// https://github.com/redwoodjs/redwood/issues/6322
workers: {
restart: true,
// This limits concurrency to a single thread; may also be required but
// haven't tested interactions between your tests and test files at scale
initial: 1,
regular: 1,
},
// This also helps address the memory leak issue and reduces the time Wallaby
// waits for its worker processes to finish
globalSetupTeardownTimeout: 100,
});
Please be sure to select to use your configuration file (instructions in our docs, method varies depending on your editor) so that Wallaby uses these settings instead of automatic configuration. Wallaby.js Introduction: Configuration