Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mhennoch committed Sep 19, 2024
1 parent 7798d3a commit 169e32a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
import { strict as assert } from 'assert';
import * as nock from 'nock';
import { after, before, describe, it } from 'node:test';
import { after, before, beforeEach, describe, it } from 'node:test';
import * as os from 'os';
import { ElasticsearchInstrumentation } from '../../../../src/instrumentations/external/elasticsearch';

import { getTestSpans, setInstrumentation } from '../setup';
import { getTestSpans, setInstrumentation, exporter, provider } from '../setup';

const instrumentation = new ElasticsearchInstrumentation();

provider.register();
import { Client } from '@elastic/elasticsearch';
const esMockUrl = 'http://localhost:9200';
const esNock = nock(esMockUrl);
Expand All @@ -43,6 +43,10 @@ describe('elasticsearch instrumentation', () => {
);
});

beforeEach(() => {
exporter.reset();
});

after(() => {
instrumentation.disable();
});
Expand Down
7 changes: 6 additions & 1 deletion test/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { _setDefaultOptions, startMetrics } from '../src/metrics';
import { cleanEnvironment, TestMetricReader } from './utils';
import { strict as assert } from 'assert';
import { describe, it, after, beforeEach } from 'node:test';
import { inspect } from 'util';

function emptyCounter() {
return {
Expand Down Expand Up @@ -70,7 +71,11 @@ describe('metrics', () => {
metrics.start();

await new Promise((resolve) => setTimeout(resolve, 10));
assert.notDeepStrictEqual(metrics.collect(), stats);
const stats2 = metrics.collect();
console.log(inspect(stats2, {showHidden: false, depth: null, colors: true}));

Check failure on line 75 in test/metrics.test.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `inspect(stats2,·{showHidden:·false,·depth:·null,·colors:·true})` with `⏎········inspect(stats2,·{·showHidden:·false,·depth:·null,·colors:·true·})⏎······`
console.log('------------------------------');
console.log(inspect(stats, {showHidden: false, depth: null, colors: true}));

Check failure on line 77 in test/metrics.test.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `inspect(stats,·{showHidden:·false,·depth:·null,·colors:·true})` with `⏎········inspect(stats,·{·showHidden:·false,·depth:·null,·colors:·true·})⏎······`
assert.notDeepStrictEqual(stats2, stats);
});

it('is possible to reset native counters', () => {
Expand Down

0 comments on commit 169e32a

Please sign in to comment.