ui_migration node(pack) add test:unit command
This commit is contained in:
parent
e803d60013
commit
d75051df4a
8 changed files with 72 additions and 22 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -94,7 +94,7 @@ openflexure_settings/
|
||||||
# Files created by test utilities
|
# Files created by test utilities
|
||||||
/tests/unit_tests/utilities/*.pstats
|
/tests/unit_tests/utilities/*.pstats
|
||||||
/tests/unit_tests/utilities/*.png
|
/tests/unit_tests/utilities/*.png
|
||||||
|
coverage/
|
||||||
# Files created by simulator
|
# Files created by simulator
|
||||||
openflexure/
|
openflexure/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,14 @@ eslint:
|
||||||
script:
|
script:
|
||||||
- npm run lint
|
- npm run lint
|
||||||
- npm run lint:style
|
- npm run lint:style
|
||||||
|
# The test run if only
|
||||||
|
- npm run test:unit
|
||||||
|
artifacts:
|
||||||
|
name: "vitest-coverage-$CI_COMMIT_REF_SLUG"
|
||||||
|
when: always
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- coverage/
|
||||||
|
|
||||||
# Build JS app
|
# Build JS app
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
|
|
@ -73,5 +73,22 @@ export default [
|
||||||
"pinia/require-setup-store-properties-export": "warn",
|
"pinia/require-setup-store-properties-export": "warn",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
files: ["src/tests/unit/**/*.spec.js"],
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
describe: "readonly",
|
||||||
|
it: "readonly",
|
||||||
|
expect: "readonly",
|
||||||
|
vi: "readonly",
|
||||||
|
beforeEach: "readonly",
|
||||||
|
afterEach: "readonly",
|
||||||
|
mockLogData: "readonly", // Prevents unused global mock variable warnings
|
||||||
|
afterAll: "readonly",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
prettierConfig,
|
prettierConfig,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
25
webapp/package-lock.json
generated
25
webapp/package-lock.json
generated
|
|
@ -30,8 +30,9 @@
|
||||||
"core-js": "^3.46.0",
|
"core-js": "^3.46.0",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^10.1.0",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-pinia": "^0.4.2",
|
"eslint-plugin-pinia": "^0.4.2",
|
||||||
"eslint-plugin-prettier": "^5.1.0",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"eslint-plugin-vue": "^9.20.0",
|
"eslint-plugin-vue": "^9.20.0",
|
||||||
"happy-dom": "^20.9.0",
|
"happy-dom": "^20.9.0",
|
||||||
"jsdom": "^29.1.1",
|
"jsdom": "^29.1.1",
|
||||||
|
|
@ -1703,6 +1704,19 @@
|
||||||
"prettier": ">= 3.0.0"
|
"prettier": ">= 3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@vue/eslint-config-prettier/node_modules/eslint-config-prettier": {
|
||||||
|
"version": "9.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz",
|
||||||
|
"integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@vue/reactivity": {
|
"node_modules/@vue/reactivity": {
|
||||||
"version": "3.5.33",
|
"version": "3.5.33",
|
||||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.33.tgz",
|
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.33.tgz",
|
||||||
|
|
@ -2738,14 +2752,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-config-prettier": {
|
"node_modules/eslint-config-prettier": {
|
||||||
"version": "9.1.2",
|
"version": "10.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz",
|
||||||
"integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
|
"integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"eslint-config-prettier": "bin/cli.js"
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
},
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/eslint-config-prettier"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": ">=7.0.0"
|
"eslint": ">=7.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
"lint:fix": "eslint . --fix --ignore-pattern .gitignore",
|
"lint:fix": "eslint . --fix --ignore-pattern .gitignore",
|
||||||
"lint:style": "stylelint \"src/**/*.{vue,less,css}\" --max-warnings=0",
|
"lint:style": "stylelint \"src/**/*.{vue,less,css}\" --max-warnings=0",
|
||||||
"lint:style:fix": "stylelint \"src/**/*.{vue,less,css}\" --fix",
|
"lint:style:fix": "stylelint \"src/**/*.{vue,less,css}\" --fix",
|
||||||
"unitest": "vitest src/tests/unit/LoggingContent.spec.js --no-cache --mode test --detectAsyncLeaks --coverage --isolate --silent --changed --logHeapUsage"
|
"test:unit": "NODE_OPTIONS=--expose-gc vitest run src/tests/unit/ --no-cache --mode test --detectAsyncLeaks --coverage --isolate=true --pool=forks --silent --logHeapUsage"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vueuse/core": "^14.1.0",
|
"@vueuse/core": "^14.1.0",
|
||||||
|
|
@ -40,8 +40,9 @@
|
||||||
"core-js": "^3.46.0",
|
"core-js": "^3.46.0",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^10.1.0",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-pinia": "^0.4.2",
|
"eslint-plugin-pinia": "^0.4.2",
|
||||||
"eslint-plugin-prettier": "^5.1.0",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"eslint-plugin-vue": "^9.20.0",
|
"eslint-plugin-vue": "^9.20.0",
|
||||||
"happy-dom": "^20.9.0",
|
"happy-dom": "^20.9.0",
|
||||||
"jsdom": "^29.1.1",
|
"jsdom": "^29.1.1",
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-default uk-width-1-1"
|
class="uk-button uk-button-default uk-width-1-1"
|
||||||
type="button"
|
type="button"
|
||||||
@click="updateLogs()"
|
|
||||||
data-test-id="update-btn"
|
data-test-id="update-btn"
|
||||||
|
@click="updateLogs()"
|
||||||
>
|
>
|
||||||
Refresh Logs
|
Refresh Logs
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
import { shallowMount, flushPromises } from "@vue/test-utils";
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
import { createTestingPinia } from "@pinia/testing";
|
import { createTestingPinia } from "@pinia/testing";
|
||||||
import { setActivePinia } from 'pinia';
|
import { setActivePinia } from "pinia";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
@ -38,7 +38,7 @@ describe("Test LoggingContent.vue", () => {
|
||||||
|
|
||||||
// Things to do before each test
|
// Things to do before each test
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
vi.useFakeTimers()
|
vi.useFakeTimers();
|
||||||
// Reset mocks before each test
|
// Reset mocks before each test
|
||||||
vi.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
|
|
||||||
|
|
@ -69,23 +69,23 @@ describe("Test LoggingContent.vue", () => {
|
||||||
});
|
});
|
||||||
// flush so we avoid leaving uncompleted processes running on background
|
// flush so we avoid leaving uncompleted processes running on background
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
vi.advanceTimersByTime(1000)
|
vi.advanceTimersByTime(1000);
|
||||||
vi.useRealTimers()
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Tear down wrapper, unmount testing component
|
// Tear down wrapper, unmount testing component
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
wrapper.unmount() // Clean up virtual DOM and memory bindings
|
wrapper.unmount(); // Clean up virtual DOM and memory bindings
|
||||||
}
|
}
|
||||||
setActivePinia(undefined)
|
setActivePinia(undefined);
|
||||||
document.body.innerHTML = ''
|
document.body.innerHTML = "";
|
||||||
|
|
||||||
if (global.gc) {
|
if (global.gc) {
|
||||||
global.gc() // Forces V8 engine to immediately run Garbage Collection
|
global.gc(); // Forces V8 engine to immediately run Garbage Collection
|
||||||
}
|
}
|
||||||
vi.clearAllTimers()
|
vi.clearAllTimers();
|
||||||
vi.useRealTimers()
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test 1: Render check, if things do exist in the page as intended
|
// Test 1: Render check, if things do exist in the page as intended
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default defineConfig({
|
||||||
|
|
||||||
test: {
|
test: {
|
||||||
css: false,
|
css: false,
|
||||||
pool: 'forks',
|
pool: "forks",
|
||||||
singleThread: true,
|
singleThread: true,
|
||||||
|
|
||||||
define: {
|
define: {
|
||||||
|
|
@ -28,16 +28,23 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
|
|
||||||
coverage: {
|
coverage: {
|
||||||
provider: 'v8',
|
provider: "v8",
|
||||||
clean: true,
|
clean: true,
|
||||||
cleanOnStart: true,
|
cleanOnStart: true,
|
||||||
},
|
reporter: ["text", "html"],
|
||||||
|
|
||||||
|
thresholds: {
|
||||||
|
lines: 70,
|
||||||
|
statements: 70,
|
||||||
|
functions: 50,
|
||||||
|
branches: 40,
|
||||||
|
},
|
||||||
|
},
|
||||||
deps: {
|
deps: {
|
||||||
optimizer: {
|
optimizer: {
|
||||||
web: {
|
web: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
include: ['@mui/material', 'lucide-react'], // Add your largest component dependencies here
|
include: ["@mui/material", "lucide-react"], // Add your largest component dependencies here
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue