-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
In upgrading to AH 29 I followed the advice and blew up the config subdir. (a bit questionable advice???) so I lost my next.ts. When I used the one from this README it took me a while to figure out why my jest tests would all fail with actionhero.start()
This is assuming a mono repo config with "api" and "web" subdirectories with AH running in api and next running in web...
In order for the jest tests to run in the actionhero api directory, you have to disable next so actionhero.start() will work in the tests. What I had before was a jest.setup.js in the api directory that says:
process.env.NEXT_DISABLED = "true";
The next.ts example in README.md does not skip enabling the plugin for tests.
// from src/config/next.ts
// learn more about the next.js app options here https://nextjs.org/docs/advanced-features/custom-server
const namespace = "next";
declare module "actionhero" {
export interface ActionheroConfigInterface {
[namespace]: ReturnType<typeof DEFAULT[typeof namespace]>;
}
}
const env = process.env.NODE_ENV ? process.env.NODE_ENV : "development";
export const DEFAULT = {
[namespace]: () => {
return {
enabled: true,
dev: process.env.NEXT_DEVELOPMENT_MODE
? process.env.NEXT_DEVELOPMENT_MODE === "false"
? false
: true
: env === "development",
quiet: false,
};
},
};
I had to change the logic on the enable: true line to read that NEXT_ENABLED from jest.setup.js and do
enabled: process.env.NEXT_DISABLED === "true" ? false : true,
Now my jest tests will run in api. Maybe some note of this could be made in the README?