Skip to content

updated more javascript to typescript so that everything is compiled … #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"scripts": {
"build": "lerna run build",
"clean": "rm -fR packages/*/dist",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"start:otel-receiver": "lerna run --scope @traceloop/otel-receiver start",
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-environment-otel/index.js

This file was deleted.

9 changes: 7 additions & 2 deletions packages/jest-environment-otel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
"version": "0.8.0",
"license": "Apache-2.0",
"type": "commonjs",
"main": "./index.js",
"main": "./dist/index.js",
"module": "./src/index.ts",
"types": "dist/index.d.ts",
"exports": {
".": "./index.js",
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./setup": "./setup.js",
"./teardown": "./teardown.js",
"./package.json": "./package.json"
Expand Down
11 changes: 10 additions & 1 deletion packages/jest-environment-otel/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ export default [
plugins: [swcPlugin, typescript({ tsconfig: '../../tsconfig.json' })],
}),
bundle({
input: 'src/env.js',
input: 'src/env.ts',
output: {
file: 'dist/env.js',
format: 'cjs',
interop: 'compat',
},
plugins: [swcPlugin, typescript({ tsconfig: '../../tsconfig.json' })],
}),
bundle({
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'cjs',
interop: 'compat',
},
plugins: [swcPlugin, typescript({ tsconfig: '../../tsconfig.json' })],
}),
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NodeEnvironment from 'jest-environment-node';
import { readConfig } from './readConfig';

const handleError = (error) => {
const handleError = (error: Error) => {
process.emit('uncaughtException', error);
};

Expand All @@ -18,7 +18,7 @@ const getWorkerIndex = () => process.env.JEST_WORKER_ID - 1;
class OpenTelemetryEnvironment extends NodeEnvironment {
// Jest is not available here, so we have to reverse engineer
// the setTimeout function, see https://github.com/facebook/jest/blob/v23.1.0/packages/jest-runtime/src/index.js#L823
setTimeout(timeout) {
setTimeout(timeout: number) {
if (this.global.jasmine) {
// eslint-disable-next-line no-underscore-dangle
this.global.jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-environment-otel/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ export async function setup(jestConfig: JestConfig = {}) {
}

if (!config?.useLocalOtelReceiver) {
console.log('NOT USING LOCAL OTEL RECEIVER', config);
return;
}

try {
console.log('OTEL setting up local test server');
await setupServer({
command: 'node ./node_modules/@traceloop/otel-receiver/dist/index.js',
// debug: true,
Expand Down
5 changes: 5 additions & 0 deletions packages/jest-environment-otel/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// import { teardown, setup } from './global';
import { OpenTelemetryEnvironment } from './env';

export default OpenTelemetryEnvironment;
// export { setup, teardown };
2 changes: 1 addition & 1 deletion packages/otel-receiver/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const startServer = async () => {
});

_server = app.listen(port, () => {
console.log(`otel-receiver listening at port ${port}`);
console.log(`otel-receiver listening at port ${port}`);
});
};

Expand Down