Skip to content

Commit a441ba6

Browse files
authored
chore(tests): update testing dependencies (#2842)
* chore(tests): update mock implementations for consistency Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(tests): update mock implementations for consistency Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(tests): enhance type definitions for mock functions in test files Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(importV1): update coverage ignore comments for clarity Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(importV1): clarify coverage ignore comments and enhance logger tests Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(importV1): update v8 ignore comments for clarity Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(test-frontend): update docker build command to use --no-cache option Signed-off-by: John Bair <john.bair@swirldslabs.com> * chore(docker): update redis service to use official image and add keyspace notifications Signed-off-by: John Bair <john.bair@swirldslabs.com> --------- Signed-off-by: John Bair <john.bair@swirldslabs.com>
1 parent 6095dfa commit a441ba6

16 files changed

Lines changed: 787 additions & 641 deletions

File tree

NOTICE

Lines changed: 115 additions & 62 deletions
Large diffs are not rendered by default.

back-end/docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ services:
112112
depends_on:
113113
- database
114114
redis:
115-
build: ./redis
115+
image: redis
116116
container_name: cache
117+
command: redis-server --notify-keyspace-events Ex
117118
ports:
118119
- "6380:6379"
119120
volumes:

back-end/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"create-admin": "npx ts-node ./scripts/create-admin.ts",
2828
"create-users": "npx ts-node ./scripts/add-users.ts",
2929
"deploy:dev": "sh ./k8s/dev/deploy.sh",
30-
"test:libs": "jest --testPathPattern='libs/.*\\.spec\\.ts$'",
30+
"test:libs": "jest --testPathPatterns='libs/.*\\.spec\\.ts$'",
3131
"test:migrations": "pnpm --filter=typeorm test",
3232
"test:all": "INCLUDE_LIBS=0 pnpm --filter=api test && INCLUDE_LIBS=0 pnpm --filter=chain test && INCLUDE_LIBS=0 pnpm --filter=notifications test && pnpm test:libs && pnpm --filter=typeorm test",
3333
"test:cov:all": "pnpm --filter=api test:cov && pnpm --filter=chain test:cov && pnpm --filter=notifications test:cov && pnpm --filter=typeorm test:cov",
@@ -82,13 +82,13 @@
8282
"devDependencies": {
8383
"@eslint/eslintrc": "3.3.5",
8484
"@eslint/js": "10.0.1",
85-
"@hashgraph/hedera-local": "2.39.4",
85+
"@hashgraph/hedera-local": "2.40.1",
8686
"@nestjs/cli": "11.0.16",
8787
"@nestjs/schematics": "11.0.9",
8888
"@nestjs/testing": "catalog:nestjs-core",
89-
"@testcontainers/postgresql": "11.13.0",
90-
"@testcontainers/rabbitmq": "11.13.0",
91-
"@testcontainers/redis": "11.13.0",
89+
"@testcontainers/postgresql": "catalog:testcontainers",
90+
"@testcontainers/rabbitmq": "catalog:testcontainers",
91+
"@testcontainers/redis": "catalog:testcontainers",
9292
"@types/express": "5.0.6",
9393
"@types/jest": "catalog:",
9494
"@types/node": "catalog:",
@@ -104,12 +104,12 @@
104104
"eslint-plugin-prettier": "5.5.5",
105105
"globals": "17.6.0",
106106
"jest": "catalog:",
107-
"jest-mock-extended": "4.0.0",
107+
"jest-mock-extended": "4.0.1",
108108
"picocolors": "1.1.1",
109109
"prettier": "catalog:",
110110
"source-map-support": "0.5.21",
111111
"supertest": "7.2.2",
112-
"testcontainers": "11.13.0",
112+
"testcontainers": "catalog:testcontainers",
113113
"ts-jest": "catalog:",
114114
"ts-loader": "catalog:",
115115
"ts-node": "catalog:",

front-end/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"@types/semver": "catalog:",
7979
"@types/unzipper": "0.10.11",
8080
"@vitejs/plugin-vue": "5.2.4",
81-
"@vitest/coverage-v8": "3.2.4",
81+
"@vitest/coverage-v8": "catalog:vitest",
8282
"@vue/eslint-config-prettier": "10.2.0",
8383
"@vue/eslint-config-typescript": "14.1.3",
8484
"@vue/test-utils": "2.4.6",
@@ -97,7 +97,7 @@
9797
"vite-plugin-electron": "0.29.1",
9898
"vite-plugin-eslint": "1.8.1",
9999
"vite-plugin-vue-devtools": "7.7.9",
100-
"vitest": "3.2.4",
100+
"vitest": "catalog:vitest",
101101
"vitest-mock-extended": "3.1.1",
102102
"vue": "3.5.29",
103103
"vue-tsc": "2.2.12"

front-end/src/main/services/localUser/importV1.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ async function filterCandidate(filePath: string): Promise<V1ImportCandidate | nu
4343
transactionBytes: txHex,
4444
nodeSignatures: jsonObj,
4545
};
46+
/* v8 ignore start */
4647
} else {
47-
/* It's unclear how we can get a transaction without id => we disable code coverage here */
48-
/* c8 ignore next */
4948
result = null
50-
/* c8 ignore next */
5149
}
50+
/* v8 ignore stop */
5251
} else {
5352
result = null;
5453
}

front-end/src/tests/main/db/init.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@ vi.mock('path', () => ({
2323
join: vi.fn(),
2424
},
2525
}));
26-
vi.mock('better-sqlite3', () => ({
27-
default: vi.fn().mockReturnValue({
28-
prepare: vi.fn(() => ({
29-
run: vi.fn(),
30-
})),
26+
vi.mock('better-sqlite3', () => {
27+
const mockInstance = {
28+
prepare: vi.fn(() => ({ run: vi.fn() })),
3129
exec: vi.fn(),
3230
inTransaction: true,
33-
}),
34-
}));
31+
};
32+
return {
33+
default: vi.fn(function () {
34+
return mockInstance;
35+
}),
36+
};
37+
});
3538
vi.mock('fsp', () => ({
3639
readdir: vi.fn(),
3740
readFile: vi.fn(),

front-end/src/tests/main/db/prisma.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ vi.mock('path', () => ({
2222
}));
2323

2424
vi.mock('@prisma/adapter-better-sqlite3', () => ({
25-
PrismaBetterSqlite3: vi.fn(() => ({})),
25+
PrismaBetterSqlite3: vi.fn(function () {
26+
return {};
27+
}),
2628
}));
2729

2830
vi.mock('@prisma/client', () => ({
29-
PrismaClient: vi.fn(() => ({
30-
$connect: vi.fn(),
31-
$disconnect: vi.fn(),
32-
})),
31+
PrismaClient: vi.fn(function () {
32+
return {
33+
$connect: vi.fn(),
34+
$disconnect: vi.fn(),
35+
};
36+
}),
3337
}));
3438

3539
describe('Database path', () => {

front-end/src/tests/main/index.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ describe('Electron entry file', async () => {
8383
return handler[1];
8484
};
8585

86-
vi.mocked(BrowserWindow).mockReturnValue({
86+
const mockBrowserWindowInstance = {
8787
on: vi.fn(),
8888
close: vi.fn(),
8989
isMinimized: vi.fn(),
9090
restore: vi.fn(),
9191
focus: vi.fn(),
92-
} as unknown as BrowserWindow);
92+
};
93+
vi.mocked(BrowserWindow).mockImplementation(function () {
94+
return mockBrowserWindowInstance;
95+
} as unknown as typeof BrowserWindow);
9396

9497
test('Should initialize the main process', async () => {
9598
is.dev = false;

front-end/src/tests/main/modules/ipcHandlers/utils.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ describe('registerUtilsListeners', () => {
452452
};
453453

454454
vi.mocked(X509Certificate).mockImplementation(
455-
() => mockX509Certificate as unknown as X509Certificate,
455+
function () { return mockX509Certificate; } as unknown as typeof X509Certificate,
456456
);
457457
vi.mocked(createHash).mockReturnValue({
458458
update: vi.fn().mockReturnThis(),
@@ -480,7 +480,7 @@ describe('registerUtilsListeners', () => {
480480
};
481481

482482
vi.mocked(X509Certificate).mockImplementation(
483-
() => mockX509Certificate as unknown as X509Certificate,
483+
function () { return mockX509Certificate; } as unknown as typeof X509Certificate,
484484
);
485485
vi.mocked(createHash).mockReturnValue({
486486
update: vi.fn().mockReturnThis(),
@@ -507,7 +507,7 @@ describe('registerUtilsListeners', () => {
507507
};
508508

509509
vi.mocked(X509Certificate).mockImplementation(
510-
() => mockX509Certificate as unknown as X509Certificate,
510+
function () { return mockX509Certificate; } as unknown as typeof X509Certificate,
511511
);
512512
vi.mocked(createHash).mockReturnValue({
513513
update: vi.fn().mockReturnThis(),

front-end/src/tests/main/modules/logger.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ describe('logger', () => {
161161
);
162162
});
163163

164+
test('log method routes through info level', () => {
165+
createLogger('renderer.websocket').log('test message');
166+
167+
expect(rootLogger.processMessage).toHaveBeenCalledWith(
168+
expect.objectContaining({
169+
data: ['test message'],
170+
level: 'info',
171+
logId: 'renderer.websocket',
172+
}),
173+
);
174+
});
175+
164176
test('uses fixed component names for updater and database loggers', () => {
165177
getAppUpdateLogger().info('Checking for update');
166178
getDatabaseLogger().error('Database failed');

0 commit comments

Comments
 (0)