Skip to content

Commit

Permalink
fix: ts-mocha allow recursively loading files (#233)
Browse files Browse the repository at this point in the history
* fix: ts-mocha allow recursively loading files
  • Loading branch information
mayurkale22 authored and OlivierAlbertini committed Sep 3, 2019
1 parent 3f90bf9 commit af5d88a
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-basic-tracer/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"clean": "rimraf build/*",
Expand Down
5 changes: 4 additions & 1 deletion packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts
Expand Up @@ -171,6 +171,7 @@ describe('BasicTracer', () => {
const tracer = new BasicTracer({
sampler: NEVER_SAMPLER,
scopeManager: new NoopScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span');
assert.ok(span instanceof NoRecordingSpan);
Expand All @@ -193,10 +194,11 @@ describe('BasicTracer', () => {
assert.strictEqual(span.isRecordingEvents(), true);
});

it('should not create real span when not sampled and recording events false', () => {
it('should not create real span when not sampled and recording events false', () => {
const tracer = new BasicTracer({
sampler: NEVER_SAMPLER,
scopeManager: new NoopScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span', { isRecordingEvents: false });
assert.ok(span instanceof NoRecordingSpan);
Expand All @@ -208,6 +210,7 @@ describe('BasicTracer', () => {
const tracer = new BasicTracer({
sampler: NEVER_SAMPLER,
scopeManager: new NoopScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span');
assert.ok(span instanceof NoRecordingSpan);
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-jaeger/package.json
Expand Up @@ -5,7 +5,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-zipkin/package.json
Expand Up @@ -5,7 +5,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-node-tracer/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"clean": "rimraf build/*",
Expand Down
28 changes: 23 additions & 5 deletions packages/opentelemetry-node-tracer/test/NodeTracer.test.ts
Expand Up @@ -21,10 +21,12 @@ import {
HttpTraceContext,
NEVER_SAMPLER,
NoopLogger,
NOOP_SPAN,
NoRecordingSpan,
} from '@opentelemetry/core';
import { AsyncHooksScopeManager } from '@opentelemetry/scope-async-hooks';
import { NodeTracer } from '../src/NodeTracer';
import { TraceOptions } from '@opentelemetry/types';
import { Span } from '@opentelemetry/basic-tracer';

describe('NodeTracer', () => {
describe('constructor', () => {
Expand Down Expand Up @@ -83,6 +85,7 @@ describe('NodeTracer', () => {
it('should start a span with name only', () => {
const tracer = new NodeTracer({
scopeManager: new AsyncHooksScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span');
assert.ok(span);
Expand All @@ -91,6 +94,7 @@ describe('NodeTracer', () => {
it('should start a span with name and options', () => {
const tracer = new NodeTracer({
scopeManager: new AsyncHooksScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span', {});
assert.ok(span);
Expand All @@ -100,16 +104,30 @@ describe('NodeTracer', () => {
const tracer = new NodeTracer({
sampler: NEVER_SAMPLER,
scopeManager: new AsyncHooksScopeManager(),
logger: new NoopLogger(),
});
const span = tracer.startSpan('my-span');
assert.deepStrictEqual(span, NOOP_SPAN);
assert.ok(span instanceof NoRecordingSpan);
assert.strictEqual(span.context().traceOptions, TraceOptions.UNSAMPLED);
assert.strictEqual(span.isRecordingEvents(), false);
});

// @todo: implement
it('should start a Span with always sampling');

// @todo: implement
it('should set default attributes on span');
it('should set default attributes on span', () => {
const defaultAttributes = {
foo: 'bar',
};
const tracer = new NodeTracer({
scopeManager: new AsyncHooksScopeManager(),
defaultAttributes,
});

const span = tracer.startSpan('my-span') as Span;
assert.ok(span instanceof Span);
assert.deepStrictEqual(span.attributes, defaultAttributes);
});
});

describe('.getCurrentSpan()', () => {
Expand Down Expand Up @@ -178,7 +196,7 @@ describe('NodeTracer', () => {
it('should call exporters with span data');
});

describe('getBinaryFormat', () => {
describe('.getBinaryFormat()', () => {
it('should get default binary formatter', () => {
const tracer = new NodeTracer({
scopeManager: new AsyncHooksScopeManager(),
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-grpc/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http2/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-https/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-mongodb/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-redis/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-scope-async-hooks/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"clean": "rimraf build/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-scope-base/package.json
Expand Up @@ -6,7 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"tdd": "yarn test -- --watch-extensions ts --watch",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"clean": "rimraf build/*",
Expand Down

0 comments on commit af5d88a

Please sign in to comment.