Skip to content

Commit 4095ba5

Browse files
committed
chore: replace jest by vitest
1 parent 587ae5d commit 4095ba5

File tree

6 files changed

+36
-28
lines changed

6 files changed

+36
-28
lines changed

lambdas/libs/aws-powertools-util/jest.config.ts

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

lambdas/libs/aws-powertools-util/src/logger/logger.child.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Context } from 'aws-lambda';
22

33
import { addPersistentContextToChildLogger, createChildLogger, logger, setContext } from '.';
4+
import { describe, test, expect, beforeEach, vi } from 'vitest';
5+
46

57
const childLogger = createChildLogger('child');
68
addPersistentContextToChildLogger({ child: 'child' });

lambdas/libs/aws-powertools-util/src/logger/logger.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Context } from 'aws-lambda';
22

33
import { logger, setContext } from '../';
4+
import { describe, test, expect, beforeEach, vi } from 'vitest';
5+
46

57
beforeEach(() => {
6-
jest.clearAllMocks();
7-
jest.resetAllMocks();
8+
vi.clearAllMocks();
9+
vi.resetAllMocks();
810
});
911

1012
const context: Context = {

lambdas/libs/aws-powertools-util/src/metrics/metrics.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import { MetricUnit, Metrics } from '@aws-lambda-powertools/metrics';
22
import { createSingleMetric } from '../';
3+
import { describe, test, expect, beforeEach, vi } from 'vitest';
4+
35

46
process.env.POWERTOOLS_METRICS_NAMESPACE = 'test';
57

68
describe('A root tracer.', () => {
79
beforeEach(() => {
8-
jest.restoreAllMocks();
10+
vi.restoreAllMocks();
911
});
1012

11-
it('should create a single metric without dimensions', () => {
12-
const spy = jest.spyOn(Metrics.prototype, 'singleMetric');
13+
test('should create a single metric without dimensions', () => {
14+
const spy = vi.spyOn(Metrics.prototype, 'singleMetric');
1315
createSingleMetric('test', MetricUnit.Count, 1);
1416
expect(spy).toHaveBeenCalled();
1517
});
1618

1719
test('should create a single metric', () => {
18-
const spy = jest.spyOn(Metrics.prototype, 'singleMetric');
20+
const spy = vi.spyOn(Metrics.prototype, 'singleMetric');
1921
createSingleMetric('test', MetricUnit.Count, 1, { test: 'test' });
2022
expect(spy).toHaveBeenCalled();
2123
});

lambdas/libs/aws-powertools-util/src/tracer/tracer.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { captureLambdaHandler, getTracedAWSV3Client, tracer } from '../';
2+
import { describe, it, expect, beforeEach, vi } from 'vitest';
3+
24

35
describe('A root tracer.', () => {
46
beforeEach(() => {
5-
jest.clearAllMocks();
6-
jest.resetAllMocks();
7+
vi.clearAllMocks();
8+
vi.resetAllMocks();
79
});
810

9-
test('Should call underlying tracer.', async () => {
10-
jest.spyOn(tracer, 'captureAWSv3Client');
11+
it('Should call underlying tracer.', async () => {
12+
vi.spyOn(tracer, 'captureAWSv3Client');
1113
getTracedAWSV3Client({});
1214
expect(tracer.captureAWSv3Client).toBeCalledTimes(1);
1315
});
14-
test('Should have a working middleware', async () => {
16+
it('Should have a working middleware', async () => {
1517
const { before } = captureLambdaHandler(tracer);
1618
expect(before).toBeDefined();
1719
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { mergeConfig } from 'vitest/config';
2+
import defaultConfig from '../../vitest.base.config';
3+
4+
export default mergeConfig(defaultConfig, {
5+
test: {
6+
coverage: {
7+
include: ['src/**/*.ts'],
8+
exclude: ['src/**/*.test.ts', 'src/**/*.d.ts'],
9+
thresholds: {
10+
statements: 100,
11+
branches: 100,
12+
functions: 100,
13+
lines: 100,
14+
}
15+
},
16+
},
17+
});

0 commit comments

Comments
 (0)