From 16225acdbd3f69b5d9dd41285f8084896a607f8b Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 26 Oct 2024 19:18:40 +0800 Subject: [PATCH] Testing --- extra/test-backend.mjs | 12 ++++++++++++ package.json | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 extra/test-backend.mjs diff --git a/extra/test-backend.mjs b/extra/test-backend.mjs new file mode 100644 index 00000000..0db3ff68 --- /dev/null +++ b/extra/test-backend.mjs @@ -0,0 +1,12 @@ +// If Node.js >= 22, run `npm run test-backend-node22`, otherwise run `npm run test-backend-node20` +import * as childProcess from "child_process"; + +const version = parseInt(process.version.slice(1)); + +console.log(`Node.js version: ${version}`); + +if (version >= 22) { + childProcess.execSync("npm run test-backend-node22", { stdio: "inherit" }); +} else { + childProcess.execSync("npm run test-backend-node20", { stdio: "inherit" }); +} diff --git a/package.json b/package.json index fd974f32..ad380a6d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "build": "vite build --config ./config/vite.config.js", "test": "npm run test-backend && npm run test-e2e", "test-with-build": "npm run build && npm test", - "test-backend": "cross-env TEST_BACKEND=1 node --test test/backend-test/**/test-**.js", + "test-backend": "node extra/test-backend.mjs", + "test-backend-node20": "cross-env TEST_BACKEND=1 node --test test/backend-test", + "test-backend-node22": "cross-env TEST_BACKEND=1 node --test test/backend-test/**test-*.js", "test-e2e": "playwright test --config ./config/playwright.config.js", "test-e2e-ui": "playwright test --config ./config/playwright.config.js --ui --ui-port=51063", "playwright-codegen": "playwright codegen localhost:3000 --save-storage=./private/e2e-auth.json",