Skip to content

Commit

Permalink
test: Unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
mzl-md committed Jun 12, 2024
1 parent 8a383c0 commit 6ada9e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nodejs/packages/layer/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"require": "ts-node/register",
"spec": ["test/**/*.spec.ts"]
}
10 changes: 9 additions & 1 deletion nodejs/packages/layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts --fix",
"prepare": "npm run compile",
"compile": "tsc -p .",
"postcompile": "copyfiles 'node_modules/**' build/workspace/nodejs && copyfiles -f 'scripts/*' build/workspace && copyfiles -f 'build/src/*' build/workspace && cd build/workspace && bestzip ../layer.zip *"
"postcompile": "copyfiles 'node_modules/**' build/workspace/nodejs && copyfiles -f 'scripts/*' build/workspace && copyfiles -f 'build/src/*' build/workspace && cd build/workspace && bestzip ../layer.zip *",
"test": "mocha"
},
"keywords": [
"opentelemetry",
Expand Down Expand Up @@ -51,5 +52,12 @@
"@opentelemetry/sdk-metrics": "^1.18.1",
"@opentelemetry/sdk-trace-base": "^1.18.1",
"@opentelemetry/sdk-trace-node": "^1.18.1"
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@types/sinon": "^17.0.3",
"mocha": "^10.4.0",
"sinon": "^18.0.0",
"ts-node": "^10.9.2"
}
}
23 changes: 23 additions & 0 deletions nodejs/packages/layer/test/wrapper.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { AwsSdkInstrumentationConfig } from "@opentelemetry/instrumentation-aws-sdk";
import { stub } from "sinon";

declare global {
function configureAwsInstrumentation(
defaultConfig: AwsSdkInstrumentationConfig,
): AwsSdkInstrumentationConfig;
}

const assert = require("assert");

describe("wrapper", () => {
describe("configureAwsInstrumentation", () => {
it("is used if defined", () => {
const configureAwsInstrumentationStub = stub().returns({
suppressInternalInstrumentation: true,
});
global.configureAwsInstrumentation = configureAwsInstrumentationStub;
require("../src/wrapper");
assert(configureAwsInstrumentationStub.calledOnce);
}).timeout(10000);
});
});

0 comments on commit 6ada9e2

Please sign in to comment.