Don't load plugins in tests

This can affect the test behavior and results.
This commit is contained in:
Asher 2021-02-09 15:36:05 -06:00
parent e098df0766
commit e4e0ac43b0
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 9 additions and 8 deletions

View File

@ -9,7 +9,7 @@ main() {
# information. We must also run it from the root otherwise coverage will not # information. We must also run it from the root otherwise coverage will not
# include our source files. # include our source files.
cd "$OLDPWD" cd "$OLDPWD"
./test/node_modules/.bin/jest "$@" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@"
} }
main "$@" main "$@"

View File

@ -114,10 +114,14 @@ export const register = async (
}) })
}) })
const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined if (!process.env.CS_DISABLE_PLUGINS) {
const pluginApi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir) const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined
await pluginApi.loadPlugins() const pluginApi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
pluginApi.mount(app, wsApp) 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.json())
app.use(bodyParser.urlencoded({ extended: true })) app.use(bodyParser.urlencoded({ extended: true }))
@ -141,9 +145,6 @@ export const register = async (
app.use("/static", _static.router) app.use("/static", _static.router)
app.use("/update", update.router) app.use("/update", update.router)
app.use("/api/applications", apps.router(pluginApi))
wrapper.onDispose(() => pluginApi.dispose())
app.use(() => { app.use(() => {
throw new HttpError("Not Found", HttpCode.NotFound) throw new HttpError("Not Found", HttpCode.NotFound)
}) })