Skip to content

Commit 7cc4954

Browse files
Merge pull request #791 from SquirrelCorporation/chore-vitest-3
[CHORE] Ensure async usage in test assertions and update dependencies
2 parents 2dba31f + 68664ed commit 7cc4954

File tree

13 files changed

+237
-237
lines changed

13 files changed

+237
-237
lines changed

server/package-lock.json

Lines changed: 206 additions & 206 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "pwd && nodemon",
88
"start": "npm run build-shared && npm run build && cross-env NODE_ENV=production node dist/index.js",
99
"build": "tsc",
10-
"test": "vitest --disable-console-intercept --reporter=basic ",
10+
"test": "vitest --disable-console-intercept",
1111
"test:python:install": "PIP_BREAK_SYSTEM_PACKAGES=1 pip install -r ./src/ansible/requirements.txt",
1212
"test:python": "npm run test:python:install && npm run test:python:run",
1313
"test:python:run": "cd ./src/ansible && python3 -m unittest discover -s . -p \"*.py\"",
@@ -74,7 +74,7 @@
7474
"@eslint/js": "^9.21.0",
7575
"@types/bcrypt": "^5.0.2",
7676
"@types/cookie-parser": "^1.4.8",
77-
"@types/dockerode": "^3.3.34",
77+
"@types/dockerode": "^3.3.35",
7878
"@types/dockerode-compose": "^1.4.1",
7979
"@types/fs-extra": "^11.0.4",
8080
"@types/jsonwebtoken": "^9.0.9",
@@ -92,22 +92,22 @@
9292
"@types/supertest": "^6.0.2",
9393
"@types/uuid": "^10.0.0",
9494
"@types/multer": "^1.4.12",
95-
"@typescript-eslint/eslint-plugin": "^8.24.1",
96-
"@vitest/coverage-v8": "^3.0.6",
95+
"@typescript-eslint/eslint-plugin": "^8.25.0",
96+
"@vitest/coverage-v8": "^3.0.7",
9797
"eslint": "^9.21.0",
9898
"eslint-config-prettier": "^10.0.1",
9999
"eslint-plugin-prettier": "^5.2.3",
100100
"eslint-plugin-import-x": "^4.6.1",
101101
"@stylistic/eslint-plugin": "^4.0.1",
102-
"@typescript-eslint/parser": "^8.24.1",
102+
"@typescript-eslint/parser": "^8.25.0",
103103
"globals": "^16.0.0",
104104
"mongodb-memory-server": "^10.1.4",
105105
"node-mocks-http": "^1.16.2",
106106
"prettier": "^3.5.2",
107107
"supertest": "^7.0.0",
108108
"ts-node": "^10.9.2",
109109
"typescript": "^5.7.3",
110-
"vitest": "^3.0.6",
110+
"vitest": "^3.0.7",
111111
"@types/js-yaml": "^4.0.9",
112112
"@types/express": "^5.0.0",
113113
"memfs": "^4.17.0"

server/src/tests/unit-tests/helpers/ssh/SSHCredentialsHelper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('SSHCredentialsHelper', () => {
5757
deviceAuth.authType = SsmAnsible.SSHType.KeyBased;
5858
const result = SSHCredentialsHelper.getDockerSshConnectionOptions(device, deviceAuth);
5959

60-
expect(result).resolves.toMatchObject({
60+
await expect(result).resolves.toMatchObject({
6161
protocol: 'ssh',
6262
port: 22,
6363
username: 'apiuser',

server/src/tests/unit-tests/modules/automations/AutomationComponent.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
21
import { Automations } from 'ssm-shared-lib';
3-
import AutomationComponent from '../../../../modules/automations/AutomationComponent';
4-
import CronTriggerComponent from '../../../../modules/automations/triggers/CronTriggerComponent';
2+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
53
import DockerActionComponent from '../../../../modules/automations/actions/DockerActionComponent';
64
import PlaybookActionComponent from '../../../../modules/automations/actions/PlaybookActionComponent';
5+
import AutomationComponent from '../../../../modules/automations/AutomationComponent';
6+
import CronTriggerComponent from '../../../../modules/automations/triggers/CronTriggerComponent';
77

88
vi.mock('./../../../../modules/automations/triggers/CronTriggerComponent');
99
vi.mock('./../../../../modules/automations/actions/DockerActionComponent');
@@ -46,7 +46,7 @@ describe('init method of AutomationComponent class', () => {
4646
test('should throw error for unknown trigger type', async () => {
4747
// @ts-expect-error provoke error
4848
automation.automationChain.trigger = 'Unknown';
49-
expect(automation.init()).rejects.toThrow('Unknown trigger type');
49+
await expect(automation.init()).rejects.toThrow('Unknown trigger type');
5050
});
5151

5252
test('should properly initialize actions for docker action type', async () => {
@@ -68,6 +68,6 @@ describe('init method of AutomationComponent class', () => {
6868
test('should throw error for unknown action type', async () => {
6969
// @ts-expect-error provoke error
7070
automation.automationChain.actions[0].action = 'Unknown';
71-
expect(automation.init()).rejects.toThrow('Unknown action type');
71+
await expect(automation.init()).rejects.toThrow('Unknown action type');
7272
});
7373
});

server/src/tests/unit-tests/modules/automations/DockerActionComponent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('DockerActionComponent', () => {
104104
);
105105

106106
// An error should be thrown if the container can't be retrieved
107-
expect(dockerActionComponent.executeAction()).resolves.toBeUndefined();
107+
await expect(dockerActionComponent.executeAction()).resolves.toBeUndefined();
108108
expect(ContainerUseCases.performDockerAction).not.toHaveBeenCalled();
109109
});
110110

server/src/tests/unit-tests/modules/docker/Acr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ describe('testing Acr Registry', () => {
7272
});
7373
});
7474

75-
test('authenticate should add basic auth', () => {
75+
test('authenticate should add basic auth', async () => {
7676
// @ts-expect-error partial type
77-
expect(acr.authenticate(undefined, { headers: {} })).resolves.toEqual({
77+
await expect(acr.authenticate(undefined, { headers: {} })).resolves.toEqual({
7878
headers: {
7979
Authorization: 'Basic Y2xpZW50aWQ6Y2xpZW50c2VjcmV0',
8080
},

server/src/tests/unit-tests/modules/docker/Component.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ describe('testing Component', () => {
5656
expect(spyInit).toHaveBeenCalledTimes(1);
5757
});
5858

59-
test('register should not call init when validateConfiguration fails', () => {
59+
test('register should not call init when validateConfiguration fails', async () => {
6060
const component = new Component();
6161
component.validateConfiguration = () => {
6262
throw new Error('validation failed');
6363
};
6464
const spyInit = vi.spyOn(component, 'init');
6565
// @ts-expect-error partial type
66-
expect(component.register('id', 'type', 'name', { x: 'x' })).rejects.toThrowError(
66+
await expect(component.register('id', 'type', 'name', { x: 'x' })).rejects.toThrowError(
6767
'validation failed',
6868
);
6969
expect(spyInit).toHaveBeenCalledTimes(0);
7070
});
7171

72-
test('register should throw when init fails', () => {
72+
test('register should throw when init fails', async () => {
7373
const component = new Component();
7474
component.init = () => {
7575
throw new Error('init failed');
7676
};
7777
// @ts-expect-error partial type
78-
expect(component.register('id', 'type', 'name', { x: 'x' })).rejects.toThrowError(
78+
await expect(component.register('id', 'type', 'name', { x: 'x' })).rejects.toThrowError(
7979
'init failed',
8080
);
8181
});

server/src/tests/unit-tests/modules/docker/Ecr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ describe('testing ECR Registry', () => {
112112
});
113113
});
114114

115-
test('authenticate should call ecr auth endpoint', () => {
115+
test('authenticate should call ecr auth endpoint', async () => {
116116
// @ts-expect-error partial type
117-
expect(ecr.authenticate(undefined, { headers: {} })).resolves.toEqual({
117+
await expect(ecr.authenticate(undefined, { headers: {} })).resolves.toEqual({
118118
headers: {
119119
Authorization: 'Basic xxxxx',
120120
},

server/src/tests/unit-tests/modules/docker/Gcr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ describe('testing GCR Registry', () => {
117117
});
118118
});
119119

120-
test('authenticate should call ecr auth endpoint', () => {
120+
test('authenticate should call ecr auth endpoint', async () => {
121121
// @ts-expect-error partial type
122-
expect(gcr.authenticate({}, { headers: {} })).resolves.toEqual({
122+
await expect(gcr.authenticate({}, { headers: {} })).resolves.toEqual({
123123
headers: {
124124
Authorization: 'Bearer xxxxx',
125125
},

server/src/tests/unit-tests/modules/docker/Ghcr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ describe('testing GHCR Registry', () => {
7777
});
7878
});
7979

80-
test('authenticate should populate header with base64 bearer', () => {
80+
test('authenticate should populate header with base64 bearer', async () => {
8181
// @ts-expect-error partial type
82-
expect(ghcr.authenticate({}, { headers: {} })).resolves.toEqual({
82+
await expect(ghcr.authenticate({}, { headers: {} })).resolves.toEqual({
8383
headers: {
8484
Authorization: 'Bearer dG9rZW4=',
8585
},

0 commit comments

Comments
 (0)