From 586778f31638abe0cb3efafa86f3308ebf67e045 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Wed, 3 Aug 2022 15:30:54 -0700 Subject: [PATCH] getting browser tests to work --- .../opentelemetry-api-logs/karma.conf.js | 24 +++++++++++++++++++ .../opentelemetry-api-logs/package.json | 17 +++++++++++-- .../src/platform/index.ts | 2 +- .../test/index-webpack.ts | 20 ++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 experimental/packages/opentelemetry-api-logs/karma.conf.js create mode 100644 experimental/packages/opentelemetry-api-logs/test/index-webpack.ts diff --git a/experimental/packages/opentelemetry-api-logs/karma.conf.js b/experimental/packages/opentelemetry-api-logs/karma.conf.js new file mode 100644 index 00000000000..6174839d651 --- /dev/null +++ b/experimental/packages/opentelemetry-api-logs/karma.conf.js @@ -0,0 +1,24 @@ +/*! + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const karmaWebpackConfig = require('../../../karma.webpack'); +const karmaBaseConfig = require('../../../karma.base'); + +module.exports = (config) => { + config.set(Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig + })) +}; diff --git a/experimental/packages/opentelemetry-api-logs/package.json b/experimental/packages/opentelemetry-api-logs/package.json index 8a3e087176a..060b6968d34 100644 --- a/experimental/packages/opentelemetry-api-logs/package.json +++ b/experimental/packages/opentelemetry-api-logs/package.json @@ -64,8 +64,21 @@ "@opentelemetry/api": "^1.1.0" }, "devDependencies": { - "nyc": "^15.1.0", - "ts-mocha": "^10.0.0", + "@types/mocha": "8.2.3", + "@types/node": "14.17.33", + "@types/webpack-env": "1.16.3", + "codecov": "3.8.3", + "istanbul-instrumenter-loader": "3.0.1", + "karma": "6.3.16", + "karma-chrome-launcher": "3.1.0", + "karma-coverage-istanbul-reporter": "3.0.3", + "karma-mocha": "2.0.1", + "karma-spec-reporter": "0.0.32", + "karma-webpack": "4.0.2", + "mocha": "7.2.0", + "nyc": "15.1.0", + "ts-loader": "8.3.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" }, diff --git a/experimental/packages/opentelemetry-api-logs/src/platform/index.ts b/experimental/packages/opentelemetry-api-logs/src/platform/index.ts index 3f9ab45f9f6..cdaf8858ce5 100644 --- a/experimental/packages/opentelemetry-api-logs/src/platform/index.ts +++ b/experimental/packages/opentelemetry-api-logs/src/platform/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export * from './browser'; +export * from './node'; diff --git a/experimental/packages/opentelemetry-api-logs/test/index-webpack.ts b/experimental/packages/opentelemetry-api-logs/test/index-webpack.ts new file mode 100644 index 00000000000..061a48ccfa7 --- /dev/null +++ b/experimental/packages/opentelemetry-api-logs/test/index-webpack.ts @@ -0,0 +1,20 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const testsContext = require.context('.', true, /test$/); +testsContext.keys().forEach(testsContext); + +const srcContext = require.context('.', true, /src$/); +srcContext.keys().forEach(srcContext);