diff --git a/config/jest-puppeteer.config.js b/config/jest-puppeteer.config.js index 07830ca3..a34937c1 100644 --- a/config/jest-puppeteer.config.js +++ b/config/jest-puppeteer.config.js @@ -2,5 +2,11 @@ module.exports = { "launch": { "headless": process.env.HEADLESS_TEST || false, "userDataDir": "./data/test-chrome-profile", + args: [ + "--no-sandbox", + "--disable-setuid-sandbox", + "--disable-gpu", + "--disable-dev-shm-usage" + ], } }; diff --git a/package.json b/package.json index c7ec3d8e..83e7d25e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "build": "vite build --config ./config/vite.config.js", "test": "node test/prepare-test-server.js && node server/server.js --port=3002 --data-dir=./data/test/ --test", "test-with-build": "npm run build && npm test", - "jest": "node test/prepare-jest.js && npm run jest-frontend && npm run jest-backend && jest --config=./config/jest.config.js", + "jest": "node test/prepare-jest.js && npm run jest-frontend && npm run jest-backend && jest --runInBand --config=./config/jest.config.js", "jest-frontend": "cross-env TEST_FRONTEND=1 jest --config=./config/jest-frontend.config.js", "jest-backend": "cross-env TEST_BACKEND=1 jest --config=./config/jest-backend.config.js", "tsc": "tsc", diff --git a/server/database.js b/server/database.js index 41d91e85..fbef40bb 100644 --- a/server/database.js +++ b/server/database.js @@ -79,7 +79,7 @@ class Database { console.log(`Data Dir: ${Database.dataDir}`); } - static async connect() { + static async connect(testMode = false) { const acquireConnectionTimeout = 120 * 1000; const Dialect = require("knex/lib/dialects/sqlite3/index.js"); @@ -112,8 +112,13 @@ class Database { await R.autoloadModels("./server/model"); await R.exec("PRAGMA foreign_keys = ON"); - // Change to WAL - await R.exec("PRAGMA journal_mode = WAL"); + if (testMode) { + // Change to MEMORY + await R.exec("PRAGMA journal_mode = MEMORY"); + } else { + // Change to WAL + await R.exec("PRAGMA journal_mode = WAL"); + } await R.exec("PRAGMA cache_size = -12000"); await R.exec("PRAGMA auto_vacuum = FULL"); diff --git a/server/server.js b/server/server.js index d1fd7ff2..709a54c9 100644 --- a/server/server.js +++ b/server/server.js @@ -176,7 +176,7 @@ exports.entryPage = "dashboard"; (async () => { Database.init(args); - await initDatabase(); + await initDatabase(testMode); exports.entryPage = await setting("entryPage"); @@ -1417,14 +1417,14 @@ async function getMonitorJSONList(userID) { return result; } -async function initDatabase() { +async function initDatabase(testMode = false) { if (! fs.existsSync(Database.path)) { console.log("Copying Database"); fs.copyFileSync(Database.templatePath, Database.path); } console.log("Connecting to the Database"); - await Database.connect(); + await Database.connect(testMode); console.log("Connected"); // Patch the database diff --git a/src/components/settings/MonitorHistory.vue b/src/components/settings/MonitorHistory.vue index 95efff0e..dc33db5b 100644 --- a/src/components/settings/MonitorHistory.vue +++ b/src/components/settings/MonitorHistory.vue @@ -26,6 +26,7 @@
{{ $t("shrinkDatabaseDescription") }}