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
1 change: 1 addition & 0 deletions integration_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "0.21.1",
"datadog-lambda-js": "^3.27.0"
},
"devDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
"postbuild": "scripts/update_dist_version.sh"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.75",
"@types/aws-lambda": "^8.10.76",
"@types/aws-sdk": "^2.7.0",
"@types/jest": "^26.0.22",
"@types/jest": "^26.0.23",
"@types/mock-fs": "4.13.0",
"@types/nock": "^11.1.0",
"@types/node": "^14.14.41",
"@types/node": "^15.6.1",
"@types/promise-retry": "^1.1.3",
"@types/shimmer": "^1.0.1",
"dd-trace": "0.32.1",
"jest": "^26.6.3",
"mock-fs": "4.13.0",
"dd-trace": "0.33.2",
"jest": "^27.0.1",
"mock-fs": "4.14.0",
"nock": "13.0.11",
"prettier": "^2.2.1",
"ts-jest": "^26.5.5",
"prettier": "^2.3.0",
"ts-jest": "^27.0.1",
"tslint": "^6.1.3",
"typescript": "^4.2.4"
"typescript": "^4.3.2"
},
"dependencies": {
"aws-xray-sdk-core": "^3.3.1",
"aws-xray-sdk-core": "^3.3.3",
"bignumber.js": "^9.0.1",
"hot-shots": "8.3.1",
"promise-retry": "^2.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const mockedIncrementErrors = incrementErrorsMetric as jest.Mock<typeof incremen
const mockedIncrementInvocations = incrementInvocationsMetric as jest.Mock<typeof incrementInvocationsMetric>;

const mockARN = "arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda";
const mockContext = ({
const mockContext = {
invokedFunctionArn: mockARN,
} as any) as Context;
} as any as Context;

// const MockedListener = OriginalListenerModule.MetricsListener as jest.Mocked<
// typeof OriginalListenerModule.MetricsListener
Expand Down
8 changes: 4 additions & 4 deletions src/metrics/enhanced-metrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jest.mock("../utils/process-version");
const mockedGetProcessVersion = getProcessVersion as jest.Mock<string>;

const mockARN = "arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda";
const mockContext = ({
const mockContext = {
invokedFunctionArn: mockARN,
memoryLimitInMB: "128",
} as any) as Context;
const mockContextLocal = ({
} as any as Context;
const mockContextLocal = {
functionName: "my-test-lambda",
functionVersion: "1.0.0",
memoryLimitInMB: "128",
} as any) as Context;
} as any as Context;

describe("getRuntimeTag", () => {
it("returns a null runtime tag when version is not recognized", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("MetricsListener", () => {
shouldRetryMetrics: false,
siteURL,
});
jest.useFakeTimers();
jest.useFakeTimers("legacy");

listener.onStartInvocation({});
listener.sendDistributionMetric("my-metric", 10, false, "tag:a", "tag:b");
Expand Down Expand Up @@ -125,7 +125,7 @@ describe("MetricsListener", () => {
shouldRetryMetrics: false,
siteURL,
});
jest.useFakeTimers();
jest.useFakeTimers("legacy");

await listener.onStartInvocation({});
listener.sendDistributionMetric("my-metric", 10, false, "tag:a", "tag:b");
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/processor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Client } from "./api";
import { APIMetric, Distribution, Metric } from "./model";
import { Processor } from "./processor";

jest.useFakeTimers();
jest.useFakeTimers("legacy");

class MockAPIClient implements Client {
public metricCalls: APIMetric[][] = [];
Expand Down
8 changes: 4 additions & 4 deletions src/trace/context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe("readTraceFromHTTPEvent", () => {

describe("readTraceFromSQSEvent", () => {
it("can read from sqs source", () => {
const result = readTraceFromSQSEvent(({
const result = readTraceFromSQSEvent({
Records: [
{
body: "Hello world",
Expand All @@ -351,7 +351,7 @@ describe("readTraceFromSQSEvent", () => {
receiptHandle: "x",
},
],
} as unknown) as SQSEvent);
} as unknown as SQSEvent);
expect(result).toEqual({
parentID: "3369753143434738315",
sampleMode: SampleMode.AUTO_KEEP,
Expand All @@ -360,7 +360,7 @@ describe("readTraceFromSQSEvent", () => {
});
});
it("can handle malformed JSON", () => {
const result = readTraceFromSQSEvent(({
const result = readTraceFromSQSEvent({
Records: [
{
body: "Hello world",
Expand All @@ -387,7 +387,7 @@ describe("readTraceFromSQSEvent", () => {
receiptHandle: "x",
},
],
} as unknown) as SQSEvent);
} as unknown as SQSEvent);
expect(result).toBeUndefined();
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/trace/trigger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { readFileSync } from "fs";
import { Context } from "aws-lambda";

const mockARN = "arn:aws:lambda:us-east-1:123456789012:function:test-nodejs-lambda";
const mockContext = ({
const mockContext = {
invokedFunctionArn: mockARN,
} as any) as Context;
} as any as Context;

describe("parseEventSource", () => {
const events = [
Expand Down
6 changes: 3 additions & 3 deletions src/utils/handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { didFunctionColdStart } from "./cold-start";
import { wrap } from "./handler";
import { LogLevel, setLogLevel } from "./log";

const mockContext = ({
const mockContext = {
invokedFunctionArn: "arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda",
} as any) as Context;
} as any as Context;

beforeEach(() => {
setLogLevel(LogLevel.NONE);
Expand Down Expand Up @@ -215,7 +215,7 @@ describe("wrap", () => {
setTimeout(() => {
callback(null, { statusCode: 204, body: "The callback response" });
}, 10);
return ({ statusCode: 200, body: "The promise response" } as unknown) as void;
return { statusCode: 200, body: "The promise response" } as unknown as void;
};

let calledOriginalHandler = false;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/timer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Timer } from "./timer";

jest.useFakeTimers();
jest.useFakeTimers("legacy");

describe("Timer", () => {
it("should return on a regular interval", async () => {
Expand Down
Loading