From f7d14a811027a4acd59b2e27156a17b1a68c724d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 25 Mar 2021 16:08:09 +0000 Subject: [PATCH] Quick change to make sure the client lib always served correctly in test. --- packages/server/src/api/routes/static.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/routes/static.js b/packages/server/src/api/routes/static.js index d5d57f6d76..64500f078d 100644 --- a/packages/server/src/api/routes/static.js +++ b/packages/server/src/api/routes/static.js @@ -11,13 +11,17 @@ const router = Router() /* istanbul ignore next */ router.param("file", async (file, ctx, next) => { ctx.file = file && file.includes(".") ? file : "index.html" - - // Serving the client library from your local dir in dev - if (env.isDev() && ctx.file.startsWith("budibase-client")) { + if (!ctx.file.startsWith("budibase-client")) { + return next() + } + // test serves from require + if (env.isTest()) { + ctx.devPath = require.resolve("@budibase/client").split(ctx.file)[0] + } else if (env.isDev()) { + // Serving the client library from your local dir in dev ctx.devPath = budibaseTempDir() } - - await next() + return next() }) router