opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

[`@opentelemetry/sdk-trace-base`] refactor tests to allow use of mocha context

Open pichlermarc opened this issue 7 months ago • 4 comments
trafficstars

Description

[!IMPORTANT] This issue is reserved for attendees of OpenTelemetry ContribFest at KubeCon EU 2025 If you are attending KubeCon EU 2025, please join us at Level 3 | ICC Capital Suite 1 on Wednesday April 2, 2025 16:15 - 17:30 BST 🙌

If you are not attending KubeCon EU 2025, the remainder of this issue will be marked as "good-first-issue" starting Thursday. 🙂

Most of our code-base uses mocha for unit-testing, however, we're using a non-recommended way of providing test functions, providing arrow functions in most cases, which has some drawbacks in use of the test framework, like not being able to use the mocha context.

In an open-source project, (like in most projects) contributors try to make their code fit in with the current code-base. In the case of our tests however, this fitting-in means that this pattern is always continued.

In order to improve this situation for the code-base in this repo, we should therefore migrate our tests to the mocha-recommended pattern.

mocha documentation suggests not using lambdas so we should change our tests like so:

// from this:
describe('foo', () => {
    it('bar', () => {
        // my test code
    });
});

// to this:
describe('foo', function() {
    it('bar', function() {
        // my test code
    });
});

In order to avoid large PRs, contributions should be scoped to a single package at a time.

To pick up work on a package, please post a comment that you're working on it, and we'll go ahead and assign you. 🙂

pichlermarc avatar Apr 02 '25 13:04 pichlermarc