replace jest with vitest

This commit is contained in:
Ildar Kamalov
2025-01-31 11:56:38 +03:00
parent 77d05e550e
commit e42c051ab7
7 changed files with 2284 additions and 6218 deletions

4
.gitignore vendored
View File

@@ -33,5 +33,9 @@ AdGuardHome.exe
AdGuardHome.yaml*
coverage.txt
node_modules/
client/test-results/
client/playwright-report/
client/blob-report/
client/playwright/.cache/
!/build/gitkeep

5
client/.gitignore vendored
View File

@@ -1,5 +0,0 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

View File

@@ -1,6 +0,0 @@
export default {
testEnvironment: 'jsdom',
transform: {
'^.+\\.tsx?$': 'babel-jest',
},
};

8461
client/package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

8
client/package.json vendored
View File

@@ -10,8 +10,8 @@
"lint": "echo 'Lint temporarily disabled'",
"lint-new": "eslint './src/**/*.(ts|tsx)'",
"lint:fix": "eslint './src/**/*.(ts|tsx)' --fix",
"test": "jest",
"test:watch": "jest --watch",
"test": "vitest",
"test:watch": "vitest --watch",
"test:e2e": "npx playwright test tests/e2e",
"test:e2e:interactive": "npx playwright test --ui",
"test:e2e:debug": "npx playwright test --debug",
@@ -66,7 +66,6 @@
"@babel/preset-env": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"@playwright/test": "^1.49.1",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.4",
"@types/node": "^22.10.2",
"@types/react": "^17.0.80",
@@ -91,8 +90,6 @@
"eslint-plugin-react-hooks": "^4.6.2",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jscodeshift": "^0.15.2",
"mini-css-extract-plugin": "^2.9.0",
"path": "^0.12.7",
@@ -103,6 +100,7 @@
"stylelint": "^16.5.0",
"ts-loader": "^9.5.1",
"url-loader": "^4.1.1",
"vitest": "^3.0.4",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4",

View File

@@ -1,3 +1,5 @@
import { describe, expect, test, afterEach, vi, beforeEach, it } from 'vitest';
import { sortIp, countClientsStatistics, findAddressType, subnetMaskToBitMask } from '../helpers/helpers';
import { ADDRESS_TYPES } from '../helpers/constants';
@@ -259,7 +261,7 @@ describe('sortIp', () => {
const originalWarn = console.warn;
beforeEach(() => {
console.warn = jest.fn();
console.warn = vi.fn();
});
afterEach(() => {
@@ -347,15 +349,15 @@ describe('sortIp', () => {
});
describe('findAddressType', () => {
describe('ip', () => {
it('should return IP type for IP addresses', () => {
expect(findAddressType('127.0.0.1')).toStrictEqual(ADDRESS_TYPES.IP);
});
describe('cidr', () => {
it('should return CIDR type for CIDR addresses', () => {
expect(findAddressType('127.0.0.1/8')).toStrictEqual(ADDRESS_TYPES.CIDR);
});
describe('mac', () => {
it('should return UNKNOWN type for MAC addresses', () => {
expect(findAddressType('00:1B:44:11:3A:B7')).toStrictEqual(ADDRESS_TYPES.UNKNOWN);
});
});

8
client/vitest.config.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
environment: 'jsdom',
include: ['src/__tests__/**'],
},
});