ui_migration config(vitest) reduce heap size for unitest
This commit is contained in:
parent
591d3f6747
commit
e803d60013
3 changed files with 42 additions and 4 deletions
|
|
@ -15,7 +15,8 @@
|
|||
"lint": "eslint . --ignore-pattern .gitignore --max-warnings=0",
|
||||
"lint:fix": "eslint . --fix --ignore-pattern .gitignore",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vueuse/core": "^14.1.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { createTestingPinia } from "@pinia/testing";
|
||||
import { setActivePinia } from 'pinia';
|
||||
import axios from "axios";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
|
@ -37,8 +38,9 @@ describe("Test LoggingContent.vue", () => {
|
|||
|
||||
// Things to do before each test
|
||||
beforeEach(async () => {
|
||||
vi.useFakeTimers()
|
||||
// Reset mocks before each test
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
|
||||
// Set axios to return our fake logs
|
||||
axios.get.mockResolvedValue({ data: mockLogData });
|
||||
|
|
@ -67,11 +69,23 @@ describe("Test LoggingContent.vue", () => {
|
|||
});
|
||||
// flush so we avoid leaving uncompleted processes running on background
|
||||
await flushPromises();
|
||||
vi.advanceTimersByTime(1000)
|
||||
vi.useRealTimers()
|
||||
});
|
||||
|
||||
// Tear down wrapper, unmount testing component
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
if (wrapper) {
|
||||
wrapper.unmount() // Clean up virtual DOM and memory bindings
|
||||
}
|
||||
setActivePinia(undefined)
|
||||
document.body.innerHTML = ''
|
||||
|
||||
if (global.gc) {
|
||||
global.gc() // Forces V8 engine to immediately run Garbage Collection
|
||||
}
|
||||
vi.clearAllTimers()
|
||||
vi.useRealTimers()
|
||||
});
|
||||
|
||||
// Test 1: Render check, if things do exist in the page as intended
|
||||
|
|
|
|||
|
|
@ -19,7 +19,30 @@ export default defineConfig({
|
|||
],
|
||||
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
css: false,
|
||||
pool: 'forks',
|
||||
singleThread: true,
|
||||
|
||||
define: {
|
||||
__VUE_PROD_DEVTOOLS__: false,
|
||||
},
|
||||
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
clean: true,
|
||||
cleanOnStart: true,
|
||||
},
|
||||
|
||||
deps: {
|
||||
optimizer: {
|
||||
web: {
|
||||
enabled: true,
|
||||
include: ['@mui/material', 'lucide-react'], // Add your largest component dependencies here
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
environment: "happy-dom",
|
||||
|
||||
globals: true,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue