Skip to content

Commit 4b61cdf

Browse files
committed
migrate jest to vitest
1 parent fba34f4 commit 4b61cdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+466
-827
lines changed

lambdas/functions/ami-housekeeper/convert-to-vitest.js

Lines changed: 0 additions & 152 deletions
This file was deleted.

lambdas/functions/ami-housekeeper/jest.config.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

lambdas/functions/ami-housekeeper/package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "ts-node-dev src/local.ts",
88
"test": "NODE_ENV=test nx test",
99
"test:watch": "NODE_ENV=test nx test --watch",
10-
"lint": "yarn eslint src",
10+
"lint": "eslint src",
1111
"watch": "ts-node-dev --respawn --exit-child src/local.ts",
1212
"build": "ncc build src/lambda.ts -o dist",
1313
"dist": "yarn build && cd dist && zip ../ami-housekeeper.zip index.js",
@@ -16,23 +16,12 @@
1616
"all": "yarn build && yarn format && yarn lint && yarn test"
1717
},
1818
"devDependencies": {
19-
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
2019
"@types/aws-lambda": "^8.10.146",
21-
"@types/jest": "^29.5.14",
22-
"@types/node": "^22.13.9",
23-
"@typescript-eslint/eslint-plugin": "^8.25.0",
24-
"@typescript-eslint/parser": "^8.25.0",
2520
"@vercel/ncc": "^0.38.3",
2621
"aws-sdk-client-mock": "^4.1.0",
2722
"aws-sdk-client-mock-jest": "^4.1.0",
2823
"eslint": "^8.57.0",
2924
"eslint-plugin-prettier": "5.2.3",
30-
"jest": "^29.7.0",
31-
"jest-mock": "^29.7.0",
32-
"jest-mock-extended": "^3.0.7",
33-
"nock": "^14.0.1",
34-
"prettier": "3.4.2",
35-
"ts-jest": "^29.2.5",
3625
"ts-node": "^10.9.2",
3726
"ts-node-dev": "^2.0.0"
3827
},
@@ -42,8 +31,7 @@
4231
"@aws-sdk/client-ec2": "^3.764.0",
4332
"@aws-sdk/client-ssm": "^3.759.0",
4433
"@aws-sdk/types": "^3.734.0",
45-
"cron-parser": "^4.9.0",
46-
"typescript": "^5.7.3"
34+
"cron-parser": "^4.9.0"
4735
},
4836
"nx": {
4937
"includedScripts": [

lambdas/functions/ami-housekeeper/src/ami.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import {
1414
SSMClient,
1515
} from '@aws-sdk/client-ssm';
1616
import { mockClient } from 'aws-sdk-client-mock';
17+
import 'aws-sdk-client-mock-jest/vitest';
1718

1819
import { AmiCleanupOptions, amiCleanup, defaultAmiCleanupOptions } from './ami';
1920
import { describe, it, expect, beforeEach, vi } from 'vitest';
2021

21-
2222
process.env.AWS_REGION = 'eu-east-1';
2323
const deleteAmisOlderThenDays = 30;
2424
const date31DaysAgo = new Date(new Date().setDate(new Date().getDate() - (deleteAmisOlderThenDays + 1)));

lambdas/functions/ami-housekeeper/src/lambda.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { logger } from '@aws-github-runner/aws-powertools-util';
22
import { Context } from 'aws-lambda';
33

4-
54
import { AmiCleanupOptions, amiCleanup } from './ami';
65
import { handler } from './lambda';
7-
import { describe, it, expect, beforeEach, beforeAll, vi } from 'vitest';
8-
6+
import { describe, it, expect, beforeAll, vi } from 'vitest';
97

108
vi.mock('./ami');
119
vi.mock('@aws-github-runner/aws-powertools-util');
@@ -41,7 +39,6 @@ const context: Context = {
4139
},
4240
};
4341

44-
// Docs for testing async with jest: https://jestjs.io/docs/tutorial-async
4542
describe('Housekeeper ami', () => {
4643
beforeAll(() => {
4744
vi.resetAllMocks();

lambdas/functions/ami-housekeeper/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"extends" : "../../tsconfig.json",
33
"include": [
44
"src/**/*"
5+
],
6+
"exclude": [
7+
"src/**/*.test.ts"
58
]
69
}

lambdas/functions/ami-housekeeper/vitest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import defaultConfig from '../../vitest.base.config';
33

44
export default mergeConfig(defaultConfig, {
55
test: {
6-
setupFiles: ['./aws-vitest-setup.ts'],
6+
setupFiles: ['../../aws-vitest-setup.ts'],
77
coverage: {
88
include: ['src/**/*.ts'],
99
exclude: ['src/**/*.test.ts', 'src/**/*.d.ts'],
@@ -12,7 +12,7 @@ export default mergeConfig(defaultConfig, {
1212
branches: 100,
1313
functions: 100,
1414
lines: 100,
15-
}
15+
},
1616
},
1717
},
1818
});

lambdas/functions/control-plane/jest.config.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

lambdas/functions/control-plane/package.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "ts-node-dev src/local.ts",
88
"test": "NODE_ENV=test nx test",
99
"test:watch": "NODE_ENV=test nx test --watch",
10-
"lint": "yarn eslint src",
10+
"lint": "eslint src",
1111
"watch": "ts-node-dev --respawn --exit-child --files src/local-down.ts",
1212
"build": "ncc build src/lambda.ts -o dist",
1313
"dist": "yarn build && cd dist && zip ../runners.zip index.js",
@@ -16,24 +16,12 @@
1616
"all": "yarn build && yarn format && yarn lint && yarn test"
1717
},
1818
"devDependencies": {
19-
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
2019
"@types/aws-lambda": "^8.10.146",
21-
"@types/jest": "^29.5.14",
22-
"@types/node": "^22.13.9",
23-
"@typescript-eslint/eslint-plugin": "^8.25.0",
24-
"@typescript-eslint/parser": "^8.25.0",
2520
"@vercel/ncc": "^0.38.3",
2621
"aws-sdk-client-mock": "^4.1.0",
2722
"aws-sdk-client-mock-jest": "^4.1.0",
28-
"eslint": "^8.57.0",
29-
"eslint-plugin-prettier": "5.2.3",
30-
"jest": "^29.7.0",
31-
"jest-mock": "^29.7.0",
32-
"jest-mock-extended": "^3.0.7",
3323
"moment-timezone": "^0.5.47",
3424
"nock": "^14.0.1",
35-
"prettier": "3.4.2",
36-
"ts-jest": "^29.2.5",
3725
"ts-node": "^10.9.2",
3826
"ts-node-dev": "^2.0.0"
3927
},
@@ -50,8 +38,7 @@
5038
"@octokit/plugin-throttling": "8.2.0",
5139
"@octokit/rest": "20.1.2",
5240
"@octokit/types": "^13.8.0",
53-
"cron-parser": "^4.9.0",
54-
"typescript": "^5.7.3"
41+
"cron-parser": "^4.9.0"
5542
},
5643
"nx": {
5744
"includedScripts": [

0 commit comments

Comments
 (0)