Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
516 changes: 247 additions & 269 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@biomejs/biome": "^2.5.12",
"@types/aws-lambda": "^8.10.163",
"@types/node": "^26.4.1",
"@vitest/coverage-v8": "4.1.11",
"@vitest/coverage-v8": "5.0.0",
"esbuild": "^0.28.2",
"husky": "^9.1.7",
"lint-staged": "^17.5.0",
Expand All @@ -66,7 +66,7 @@
"typedoc-plugin-missing-exports": "^4.1.4",
"typescript": "^6.0.3",
"undici-types": "^8.10.2",
"vitest": "4.1.11"
"vitest": "5.0.0"
},
"lint-staged": {
"*.{js,ts,json}": "biome check --write --no-errors-on-unmatched",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
);
expect(console.error).toHaveBeenCalledWith(
'An error occurred in tool error-tool.',
new Error('Something went wrong')
toThrow
);
}
);
Expand Down
32 changes: 16 additions & 16 deletions packages/event-handler/tests/unit/http/converters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Converters', () => {
expect(url.searchParams.get('sort')).toBe('desc');
});

it('handles POST request with string body', () => {
it('handles POST request with string body', async () => {
// Prepare
const event = {
...baseEvent,
Expand All @@ -118,7 +118,7 @@ describe('Converters', () => {
// Assess
expect(request).toBeInstanceOf(Request);
expect(request.method).toBe('POST');
expect(request.text()).resolves.toBe('{"key":"value"}');
await expect(request.text()).resolves.toBe('{"key":"value"}');
expect(request.headers.get('Content-Type')).toBe('application/json');
});

Expand Down Expand Up @@ -189,7 +189,7 @@ describe('Converters', () => {
expect(request.method).toBe('PATCH');
});

it('decodes base64 encoded body', () => {
it('decodes base64 encoded body', async () => {
// Prepare
const originalText = 'Hello World';
const base64Text = Buffer.from(originalText).toString('base64');
Expand All @@ -205,7 +205,7 @@ describe('Converters', () => {

// Assess
expect(request).toBeInstanceOf(Request);
expect(request.text()).resolves.toBe(originalText);
await expect(request.text()).resolves.toBe(originalText);
});

it('handles single-value headers', () => {
Expand Down Expand Up @@ -522,7 +522,7 @@ describe('Converters', () => {
expect(request.url).toBe('http://localhost/test');
});

it('handles POST request with string body', () => {
it('handles POST request with string body', async () => {
// Prepare
const event = {
...baseEvent,
Expand All @@ -537,7 +537,7 @@ describe('Converters', () => {
// Assess
expect(request).toBeInstanceOf(Request);
expect(request.method).toBe('POST');
expect(request.text()).resolves.toBe('{"key":"value"}');
await expect(request.text()).resolves.toBe('{"key":"value"}');
expect(request.headers.get('Content-Type')).toBe('application/json');
});

Expand Down Expand Up @@ -580,7 +580,7 @@ describe('Converters', () => {
expect(request.body).toBe(null);
});

it('decodes base64 encoded body', () => {
it('decodes base64 encoded body', async () => {
// Prepare
const originalText = 'Hello World';
const base64Text = Buffer.from(originalText).toString('base64');
Expand All @@ -596,7 +596,7 @@ describe('Converters', () => {

// Assess
expect(request).toBeInstanceOf(Request);
expect(request.text()).resolves.toBe(originalText);
await expect(request.text()).resolves.toBe(originalText);
});

it('handles multiValueHeaders', () => {
Expand Down Expand Up @@ -730,7 +730,7 @@ describe('Converters', () => {
expect(request.url).toBe('http://api.example.com/test');
});

it('handles POST request with string body', () => {
it('handles POST request with string body', async () => {
// Prepare
const event = {
...createTestEventV2('/test', 'POST'),
Expand All @@ -744,7 +744,7 @@ describe('Converters', () => {
// Assess
expect(request).toBeInstanceOf(Request);
expect(request.method).toBe('POST');
expect(request.text()).resolves.toBe('{"key":"value"}');
await expect(request.text()).resolves.toBe('{"key":"value"}');
expect(request.headers.get('Content-Type')).toBe('application/json');
});

Expand Down Expand Up @@ -811,7 +811,7 @@ describe('Converters', () => {
expect(request.method).toBe('PATCH');
});

it('decodes base64 encoded body', () => {
it('decodes base64 encoded body', async () => {
// Prepare
const originalText = 'Hello World';
const base64Text = Buffer.from(originalText).toString('base64');
Expand All @@ -826,7 +826,7 @@ describe('Converters', () => {

// Assess
expect(request).toBeInstanceOf(Request);
expect(request.text()).resolves.toBe(originalText);
await expect(request.text()).resolves.toBe(originalText);
});

it('handles cookies array', () => {
Expand Down Expand Up @@ -1292,7 +1292,7 @@ describe('Converters', () => {
expect(result.headers.get('Cache-Control')).toBe('no-cache, no-store');
});

it('converts plain object to JSON Response with default headers', () => {
it('converts plain object to JSON Response with default headers', async () => {
// Prepare
const obj = { message: 'success' };

Expand All @@ -1302,7 +1302,7 @@ describe('Converters', () => {
// Assess
expect(result).toBeInstanceOf(Response);
expect(result.status).toBe(HttpStatusCodes.OK);
expect(result.text()).resolves.toBe(JSON.stringify(obj));
await expect(result.text()).resolves.toBe(JSON.stringify(obj));
expect(result.headers.get('Content-Type')).toBe('application/json');
});

Expand Down Expand Up @@ -1375,7 +1375,7 @@ describe('Converters', () => {
expect(result.headers.get('content-type')).toBe('text/plain');
});

it('merges headers from resHeaders with Response object, headers from Response take precedence', () => {
it('merges headers from resHeaders with Response object, headers from Response take precedence', async () => {
// Prepare
const response = new Response('Hello', {
headers: { 'content-type': 'text/plain' },
Expand All @@ -1395,7 +1395,7 @@ describe('Converters', () => {
expect(result.status).toBe(HttpStatusCodes.OK);
expect(result.headers.get('content-type')).toBe('text/plain');
expect(result.headers.get('x-custom')).toBe('value');
expect(result.text()).resolves.toBe('Hello');
await expect(result.text()).resolves.toBe('Hello');
});

it('serializes JSON object body in APIGatewayProxyResult', async () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/idempotency/tests/helpers/idempotencyUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { vi } from 'vitest';
import { type Mock, vi } from 'vitest';
import { BasePersistenceLayer } from '../../src/persistence/BasePersistenceLayer.js';
import { CachePersistenceLayer } from '../../src/persistence/CachePersistenceLayer.js';
import { DynamoDBPersistenceLayer } from '../../src/persistence/DynamoDBPersistenceLayer.js';
Expand All @@ -10,10 +10,10 @@ import type { IdempotencyRecord } from '../../src/persistence/IdempotencyRecord.
* This class is used in the unit tests.
*/
class PersistenceLayerTestClass extends BasePersistenceLayer {
public _deleteRecord = vi.fn();
public _getRecord = vi.fn();
public _putRecord = vi.fn();
public _updateRecord = vi.fn();
public _deleteRecord: Mock = vi.fn();
public _getRecord: Mock = vi.fn();
public _putRecord: Mock = vi.fn();
public _updateRecord: Mock = vi.fn();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/parameters/tests/unit/setParameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ describe('Function: setParameter', () => {
expect(DEFAULT_PROVIDERS.ssm).toBe(provider);
});

it('rethrows the error thrown by the underlying sdk client', () => {
it('rethrows the error thrown by the underlying sdk client', async () => {
// Prepare
const options: SSMSetOptions = { value: 'my-value' };
const cause = new Error('Could not send command');
client.on(PutParameterCommand).rejects(cause);

// Assess
expect(async () => {
await expect(async () => {
await setParameter(parameterName, options);
}).rejects.toThrowError(
new SetParameterError(
Expand Down
3 changes: 1 addition & 2 deletions packages/testing/src/setupEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ interface AwsSdkMatchers {
}

declare module 'vitest' {
// biome-ignore lint/suspicious/noExplicitAny: vitest typings expect an any type
interface Assertion<T = any> extends AwsSdkMatchers {
interface Assertion<R, T> extends AwsSdkMatchers {
/**
* Asserts that the logger function has been called with the expected log message
* during any call.
Expand Down
5 changes: 3 additions & 2 deletions packages/tracer/tests/helpers/mockRequests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { channel } from 'node:diagnostics_channel';
import type { URL } from 'node:url';
import { vi } from 'vitest';
import { type Mock, vi } from 'vitest';

type MockFetchOptions = {
origin?: string | URL;
Expand Down Expand Up @@ -37,11 +37,12 @@ const mockFetch = ({
const responseHeadersChannel = channel('undici:request:headers');
const errorChannel = channel('undici:request:error');

const addHeader: Mock = vi.fn();
const request = {
origin,
method: method ?? 'GET',
path,
addHeader: vi.fn(),
addHeader,
};

requestCreateChannel.publish({
Expand Down
Loading