From fb37473e72bc5dc6a3e51dc3a9b84a5b93865698 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 19 Jan 2021 16:44:42 -0600 Subject: [PATCH] Load only test plugin during tests The other plugins in my path were causing the tests to fail. --- src/node/plugin.ts | 7 ++++--- test/plugin.test.ts | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/node/plugin.ts b/src/node/plugin.ts index c2e43173..65127127 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -118,7 +118,7 @@ export class PluginAPI { * loadPlugins loads all plugins based on this.csPlugin, * this.csPluginPath and the built in plugins. */ - public async loadPlugins(): Promise { + public async loadPlugins(loadBuiltin = true): Promise { for (const dir of this.csPlugin.split(":")) { if (!dir) { continue @@ -133,8 +133,9 @@ export class PluginAPI { await this._loadPlugins(dir) } - // Built-in plugins. - await this._loadPlugins(path.join(__dirname, "../../plugins")) + if (loadBuiltin) { + await this._loadPlugins(path.join(__dirname, "../../plugins")) + } } /** diff --git a/test/plugin.test.ts b/test/plugin.test.ts index 0c4acb9e..01780eb8 100644 --- a/test/plugin.test.ts +++ b/test/plugin.test.ts @@ -15,8 +15,10 @@ describe("plugin", () => { let s: httpserver.HttpServer beforeAll(async () => { - papi = new PluginAPI(logger, `${path.resolve(__dirname, "test-plugin")}:meow`) - await papi.loadPlugins() + // Only include the test plugin to avoid contaminating results with other + // plugins that might be on the filesystem. + papi = new PluginAPI(logger, `${path.resolve(__dirname, "test-plugin")}:meow`, "") + await papi.loadPlugins(false) const app = express.default() papi.mount(app)