From e4e0ac43b045bf8e627e57fc9c7f0342007dfff9 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 9 Feb 2021 15:36:05 -0600 Subject: [PATCH] Don't load plugins in tests This can affect the test behavior and results. --- ci/dev/test.sh | 2 +- src/node/routes/index.ts | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ci/dev/test.sh b/ci/dev/test.sh index 6b0acd02a..851aa0d3b 100755 --- a/ci/dev/test.sh +++ b/ci/dev/test.sh @@ -9,7 +9,7 @@ main() { # information. We must also run it from the root otherwise coverage will not # include our source files. cd "$OLDPWD" - ./test/node_modules/.bin/jest "$@" + CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" } main "$@" diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index f91c75766..d04eac349 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -114,10 +114,14 @@ export const register = async ( }) }) - const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined - const pluginApi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir) - await pluginApi.loadPlugins() - pluginApi.mount(app, wsApp) + if (!process.env.CS_DISABLE_PLUGINS) { + const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined + const pluginApi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir) + await pluginApi.loadPlugins() + pluginApi.mount(app, wsApp) + app.use("/api/applications", apps.router(pluginApi)) + wrapper.onDispose(() => pluginApi.dispose()) + } app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: true })) @@ -141,9 +145,6 @@ export const register = async ( app.use("/static", _static.router) app.use("/update", update.router) - app.use("/api/applications", apps.router(pluginApi)) - wrapper.onDispose(() => pluginApi.dispose()) - app.use(() => { throw new HttpError("Not Found", HttpCode.NotFound) })