Skip to content

Commit 085dbc8

Browse files
Update/deps (#97)
* fix: move ts-node from dependency to peer dependency * deps: update dependencies * chore: update semver to version 5.7.2 in package-lock.json * refactor: improve test script commands and add logging to programmatic use tests --------- Co-authored-by: Felipe Plets <[email protected]>
1 parent 0895a96 commit 085dbc8

File tree

8 files changed

+795
-1047
lines changed

8 files changed

+795
-1047
lines changed

package-lock.json

Lines changed: 750 additions & 1008 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,28 @@
1515
"scripts": {
1616
"clean": "rm -rf node_modules/",
1717
"reinstall": "npm run clean && npm install",
18-
"pretest:baseline": "npm install --peer",
19-
"test:baseline": "./bin/ts-mocha -p test/baseline/tsconfig.json test/baseline/**/*.spec.ts test/typecheck/**/*.spec.ts && node test/baseline/programmatic-use-test.js",
20-
"pretest:paths": "npm install --optional",
18+
"test:baseline": "./bin/ts-mocha -p test/baseline/tsconfig.json test/baseline/**/*.spec.ts && node test/baseline/programmatic-use-test.js",
2119
"test:paths": "./bin/ts-mocha --paths -p test/paths/tsconfig.json test/paths/**/*.spec.ts && node test/paths/programmatic-use-test.js",
2220
"test:typecheck": "if ./bin/ts-mocha --type-check -p test/typecheck/tsconfig.json test/typecheck/**/*.spec.ts; then exit 1; fi && node test/typecheck/programmatic-use-test.js",
23-
"test": "npm run test:baseline & npm run test:paths & npm run test:typecheck",
21+
"test": "npm run test:baseline && npm run test:paths && npm run test:typecheck",
2422
"prepublishOnly": "npm run clean && npm install --production && npm install -D mocha && npm test"
2523
},
26-
"dependencies": {
27-
"ts-node": "7.0.1"
28-
},
2924
"devDependencies": {
30-
"@types/expect": "24.3.0",
31-
"@types/mocha": "8.0.3",
32-
"@types/node": "14.14.2",
33-
"expect": "26.6.1",
34-
"husky": "4.3.0",
35-
"mocha": "11.0.1",
25+
"@types/expect": "^24.3.2",
26+
"@types/mocha": "^10.0.10",
27+
"@types/node": "^22.13.4",
28+
"expect": "^29.7.0",
29+
"mocha": "^11.1.0",
30+
"ts-node": "^10.9.2",
3631
"tslint": "6.1.3",
37-
"typescript": "3.3.3"
32+
"typescript": "4.9.5"
3833
},
3934
"peerDependencies": {
40-
"mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X || ^11.X.X"
35+
"mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X || ^11.X.X",
36+
"ts-node": "^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X"
4137
},
4238
"optionalDependencies": {
43-
"tsconfig-paths": "^3.5.0"
39+
"tsconfig-paths": "^4.1.2"
4440
},
4541
"files": [
4642
"bin/",

test/baseline/app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as expect from 'expect';
1+
import expect from 'expect';
22
import app from './app';
33

44
describe('Running TypeScript tests in ts-node runtime without compilation', () => {
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
process.env.TS_NODE_PROJECT = './test/paths/tsconfig.json';
2-
require('../..');
3-
const Mocha = require('mocha');
4-
const path = require('path');
1+
process.env.TS_NODE_PROJECT = "./test/paths/tsconfig.json";
2+
require("../..");
3+
const Mocha = require("mocha");
4+
const path = require("path");
55

66
const mocha = new Mocha();
77
mocha.addFile(path.resolve(__dirname, `app.spec.ts`));
8-
// Add a test with a compile error to prove that type checks are off by default.
9-
mocha.addFile(path.resolve(__dirname, `../typecheck/app.spec.ts`));
8+
9+
console.log("Programmatic use test start.");
1010
mocha.run((failures) => {
11-
process.on('exit', () => {
11+
process.on("exit", () => {
12+
console.log("Programmatic use test complete.");
1213
process.exit(failures); // exit with non-zero status if there were failures
1314
});
1415
});

test/paths/app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as expect from 'expect';
1+
import expect from 'expect';
22
import { getAdder, getNumber } from './app';
33

44
describe('Running TypeScript tests in ts-node runtime without compilation', () => {
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
process.env.TS_NODE_PROJECT = './test/paths/tsconfig.json';
1+
process.env.TS_NODE_PROJECT = "./test/paths/tsconfig.json";
22
process.env.TS_CONFIG_PATHS = true;
3-
require('../..');
4-
const Mocha = require('mocha');
5-
const path = require('path');
3+
require("../..");
4+
const Mocha = require("mocha");
5+
const path = require("path");
66

77
const mocha = new Mocha();
88
mocha.addFile(path.resolve(__dirname, `app.spec.ts`));
9+
10+
console.log("Programmatic use test start.");
911
mocha.run((failures) => {
10-
process.on('exit', () => {
12+
process.on("exit", () => {
13+
console.log("Programmatic use test complete.");
1114
process.exit(failures); // exit with non-zero status if there were failures
1215
});
1316
});

test/typecheck/app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as expect from 'expect';
1+
import expect from 'expect';
22
import app from './app';
33

44
describe('Running TypeScript tests in ts-node runtime with type checks', () => {

test/typecheck/programmatic-use-test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
process.env.TS_NODE_PROJECT = './test/paths/tsconfig.json';
1+
process.env.TS_NODE_PROJECT = "./test/paths/tsconfig.json";
22
process.env.TS_TYPE_CHECK = true;
3-
require('../..');
4-
const Mocha = require('mocha');
5-
const path = require('path');
6-
const { TSError } = require('ts-node');
3+
require("../..");
4+
const Mocha = require("mocha");
5+
const path = require("path");
6+
const { TSError } = require("ts-node");
77

88
const mocha = new Mocha();
99
mocha.addFile(path.resolve(__dirname, `app.spec.ts`));
1010

1111
try {
12+
console.log("Programmatic use test start.");
1213
mocha.run(() => {
13-
process.on('exit', () => {
14-
process.exit(1); // exit with non-zero status if the tests were run at all
14+
process.on("exit", () => {
15+
console.log("Programmatic use test failed.");
16+
// exit with non-zero status if the tests were completed
17+
// as they are expected to fail
18+
process.exit(1);
1519
});
1620
});
1721
} catch (error) {
1822
if (error instanceof TSError) {
19-
// Success, we found the compile error
23+
// Success, we found the type error
24+
console.log("Programmatic use test complete.");
25+
process.exit(0);
2026
} else {
2127
throw error;
2228
}

0 commit comments

Comments
 (0)