From 407581ee07a38490a2ced7828a87b586cfbcc54e Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Wed, 13 Oct 2021 02:53:59 +0800 Subject: [PATCH] move jest config files to config dir --- babel.config.js | 4 ++++ config/jest-backend.config.js | 5 +++++ .../jest-frontend.config.js | 2 +- .../jest-puppeteer.config.js | 0 jest.config.js => config/jest.config.js | 2 +- package-lock.json | 17 +++++++++++++++-- package.json | 6 ++++-- test/backend.spec.js | 10 ++++++++++ 8 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 config/jest-backend.config.js rename jest-frontend.config.js => config/jest-frontend.config.js (76%) rename jest-puppeteer.config.js => config/jest-puppeteer.config.js (100%) rename jest.config.js => config/jest.config.js (90%) create mode 100644 test/backend.spec.js diff --git a/babel.config.js b/babel.config.js index 70266c1f7..d2ad8213a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,4 +4,8 @@ if (process.env.TEST_FRONTEND) { config.presets = ["@babel/preset-env"]; } +if (process.env.TEST_BACKEND) { + config.plugins = ["babel-plugin-rewire"]; +} + module.exports = config; diff --git a/config/jest-backend.config.js b/config/jest-backend.config.js new file mode 100644 index 000000000..1a88d9a6b --- /dev/null +++ b/config/jest-backend.config.js @@ -0,0 +1,5 @@ +module.exports = { + "rootDir": "..", + "testRegex": "./test/backend.spec.js", +}; + diff --git a/jest-frontend.config.js b/config/jest-frontend.config.js similarity index 76% rename from jest-frontend.config.js rename to config/jest-frontend.config.js index ec4ab8d8e..ab6af7f1e 100644 --- a/jest-frontend.config.js +++ b/config/jest-frontend.config.js @@ -1,5 +1,5 @@ module.exports = { - "rootDir": ".", + "rootDir": "..", "testRegex": "./test/frontend.spec.js", }; diff --git a/jest-puppeteer.config.js b/config/jest-puppeteer.config.js similarity index 100% rename from jest-puppeteer.config.js rename to config/jest-puppeteer.config.js diff --git a/jest.config.js b/config/jest.config.js similarity index 90% rename from jest.config.js rename to config/jest.config.js index 6ce5b90a6..4baaa0fb6 100644 --- a/jest.config.js +++ b/config/jest.config.js @@ -5,7 +5,7 @@ module.exports = { "__DEV__": true }, "testRegex": "./test/e2e.spec.js", - "rootDir": ".", + "rootDir": "..", "testTimeout": 30000, }; diff --git a/package-lock.json b/package-lock.json index 104b38c10..296362633 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "1.7.3", + "version": "1.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "1.7.3", + "version": "1.8.0", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "~1.2.36", @@ -64,6 +64,7 @@ "@vitejs/plugin-legacy": "~1.6.1", "@vitejs/plugin-vue": "~1.9.2", "@vue/compiler-sfc": "~3.2.19", + "babel-plugin-rewire": "^1.2.0", "core-js": "~3.18.1", "cross-env": "~7.0.3", "dns2": "~2.0.1", @@ -3331,6 +3332,12 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/babel-plugin-rewire": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-rewire/-/babel-plugin-rewire-1.2.0.tgz", + "integrity": "sha512-JBZxczHw3tScS+djy6JPLMjblchGhLI89ep15H3SyjujIzlxo5nr6Yjo7AXotdeVczeBmWs0tF8PgJWDdgzAkQ==", + "dev": true + }, "node_modules/babel-preset-current-node-syntax": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", @@ -14722,6 +14729,12 @@ "@babel/helper-define-polyfill-provider": "^0.2.2" } }, + "babel-plugin-rewire": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-rewire/-/babel-plugin-rewire-1.2.0.tgz", + "integrity": "sha512-JBZxczHw3tScS+djy6JPLMjblchGhLI89ep15H3SyjujIzlxo5nr6Yjo7AXotdeVczeBmWs0tF8PgJWDdgzAkQ==", + "dev": true + }, "babel-preset-current-node-syntax": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", diff --git a/package.json b/package.json index b4454601e..16f463c50 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,9 @@ "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 && jest ", - "jest-frontend": "cross-env TEST_FRONTEND=1 jest --config=./jest-frontend.config.js", + "jest": "node test/prepare-jest.js && npm run jest-frontend && npm run jest-backend && jest --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", "vite-preview-dist": "vite preview --host --config ./config/vite.config.js", "build-docker": "npm run build-docker-debian && npm run build-docker-alpine", @@ -59,6 +60,7 @@ "@popperjs/core": "~2.10.2", "args-parser": "~1.3.0", "axios": "~0.21.4", + "babel-plugin-rewire": "~1.2.0", "bcryptjs": "~2.4.3", "bootstrap": "~5.1.1", "chart.js": "~3.5.1", diff --git a/test/backend.spec.js b/test/backend.spec.js new file mode 100644 index 000000000..4f00c0b13 --- /dev/null +++ b/test/backend.spec.js @@ -0,0 +1,10 @@ +beforeAll(() => { + +}); + +describe("", () => { + + it("should ", () => { + + }); +});