Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Use ts-mocha to run tests (#444)
Browse files Browse the repository at this point in the history
* Use ts-mocha to run tests

* Add compile step to CI

* Update all packages to use ts-mocha

* Fix typo around pjsonVersion

* Delete spurious blank line

* Get .ts coverage for all packages

* Undo changes to opencensus-nodejs/package.json.  It needs to be compiled to .js to get the tests to pass.

* Undo ts-mocha for redis package

* Don't use ts-mocha for ocagent

* Revert package-lock.json and ocagent.ts since we aren't going to change package.json as part of this PR.

* Remove unnecessary nyc block

* Undo changes to package-lock.json

* Handle templatesDir
  • Loading branch information
Ken Ashcraft authored and mayurkale22 committed Mar 27, 2019
1 parent c5a7d07 commit 4b7d14c
Show file tree
Hide file tree
Showing 46 changed files with 1,877 additions and 109 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ unit_tests: &unit_tests
- run:
name: Install modules and dependencies.
command: npm install
- run:
name: Ensure code compiles to JS.
command: npm run compile
- run:
name: Run unit tests.
command: npm run test
Expand Down
86 changes: 86 additions & 0 deletions packages/opencensus-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions packages/opencensus-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"types": "build/src/index.d.ts",
"repository": "census-instrumentation/opencensus-node",
"scripts": {
"test": "nyc mocha build/test/**/*.js",
"test": "nyc ts-mocha -p ./tsconfig.json test/**/*.ts",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"clean": "rimraf build/*",
"check": "gts check",
"compile": "tsc -p .",
"compile:release": "tsc -p tsconfig-release.json",
"fix": "gts fix",
"prepare": "npm run compile:release",
"pretest": "npm run compile",
"posttest": "npm run check"
},
"keywords": [
Expand All @@ -38,6 +37,16 @@
"LICENSE",
"README.md"
],
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"**/*.d.ts"
],
"all": true
},
"publishConfig": {
"access": "public"
},
Expand All @@ -54,6 +63,7 @@
"intercept-stdout": "^0.1.2",
"mocha": "^6.0.0",
"nyc": "13.3.0",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "~2.9.0"
},
Expand Down
13 changes: 10 additions & 3 deletions packages/opencensus-core/src/common/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ type Package = {
};

// Load the package details. Note that the `require` is performed at runtime,
// which means the source files will be in the `/build` directory, so the
// package path is relative to that location.
const pjson: Package = require('../../../package.json');
// which means package.json will be relative to the location of this file.
// If this file has been compiled, it will be in the `/build` directory, so the
// package path is relative to that location. Otherwise, it will be relative
// to the original .ts file.
let pjson: Package;
try {
pjson = require('../../../package.json');
} catch {
pjson = require('../../package.json');
}

// Export the core package version
export const version: string = pjson.version;
86 changes: 86 additions & 0 deletions packages/opencensus-exporter-instana/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions packages/opencensus-exporter-instana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
"types": "build/src/index.d.ts",
"repository": "census-instrumentation/opencensus-node",
"scripts": {
"test": "nyc mocha build/test/**/*.js",
"test": "nyc ts-mocha -p ./tsconfig.json test/**/*.ts",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"clean": "rimraf build/*",
"check": "gts check",
"compile": "tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run check"
},
"keywords": [
Expand All @@ -36,6 +35,16 @@
"LICENSE",
"README.md"
],
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"**/*.d.ts"
],
"all": true
},
"publishConfig": {
"access": "public"
},
Expand All @@ -48,6 +57,7 @@
"mocha": "^6.0.0",
"nock": "^10.0.0",
"nyc": "13.3.0",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "~3.2.0"
},
Expand Down
Loading

0 comments on commit 4b7d14c

Please sign in to comment.