updated to reflect the testing infrastructure changes from sealgen

Summary: Ref T2697

Reviewers: #testers, kuba-orlik

Reviewed By: #testers, kuba-orlik

Subscribers: kuba-orlik

Maniphest Tasks: T2697

Differential Revision: https://hub.sealcode.org/D1323
This commit is contained in:
migueldar 2023-04-14 17:31:11 +02:00
parent 7d8417658f
commit 84a9b530d4
6 changed files with 4372 additions and 6717 deletions

6
.mocharc.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
require: ["ts-node/register", "source-map-support/register"],
recursive: true,
timeout: "10000",
spec: ["src/*.test.ts", "src/**/*.test.ts"],
};

6
.nycrc Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"include": "src",
"exclude": ""
}

10943
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,35 @@
{
"name": "module-starter",
"version": "0.0.1",
"description": "module template",
"main": "lib/index.js",
"scripts": {
"test": "node test.js",
"build": "tsc",
"prepare": "npm run build",
"test-reports": "npm run build && rm -fr .xunit coverage && npm run test -- --cover --test-report"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/mocha": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-with-tsc-error": "^0.0.7",
"mocha": "^9.1.1",
"mri": "^1.1.6",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.19",
"ts-node": "^10.2.1",
"typescript": "^4.3.5"
},
"types": "./@types/index.d.ts"
"name": "module-starter",
"version": "0.0.1",
"description": "module template",
"main": "lib/index.js",
"scripts": {
"test": "mocha",
"build": "tsc",
"prepare": "npm run build",
"clean-coverage": "rm -rf coverage .nyc_output .xunit",
"coverage": "npm run clean-coverage && nyc mocha",
"test-reports": "npm run clean-coverage && nyc --reporter clover mocha --reporter xunit --reporter-option output=.xunit",
"coverage-html": "npm run test-reports && nyc report --reporter lcov && xdg-open coverage/lcov-report/index.html"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-with-tsc-error": "^0.0.8",
"mocha": "^10.2.0",
"mri": "^1.2.0",
"nyc": "^15.1.0",
"prettier": "^2.8.7",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"types": "./@types/index.d.ts"
}

68
test.js
View File

@ -1,68 +0,0 @@
const mri = require("mri");
const { spawn } = require("child_process");
const argv = process.argv.slice(2);
const args = mri(argv);
const bin_dir = "./node_modules/.bin/";
const mocha = bin_dir + "mocha";
let mocha_options = [
"--recursive",
"--timeout=10000",
"--require",
"source-map-support/register",
"-r",
" ts-node/register"
];
if (args["test-report"]) {
mocha_options = [
...mocha_options,
"--reporter",
"xunit",
"--reporter-option",
"output=.xunit",
];
}
const mocha_files = ["src/**/*.test.ts"];
let command = [mocha, ...mocha_options, ...mocha_files];
if (args.cover) {
const nyc = [
bin_dir + "nyc",
"-all",
"--exclude",
"lib",
"--source-map",
"false",
];
if (args["cover-html"]) {
nyc.push("--reporter", "lcov");
} else {
nyc.push("--reporter", "clover");
}
command = [...nyc, ...command];
}
if (args.debug) {
command = ["node", "inspect", ...command];
}
console.log("spawning mocha...", command);
const proc = spawn(command[0], command.slice(1), {
stdio: "inherit",
env: process.env,
});
proc.on("exit", function (code) {
if (args["test-report"]) {
process.exit(0);
} else {
process.exit(code);
}
});

View File

@ -17,6 +17,6 @@
"sourceMap": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"]
"include": ["src/**/*", ],
"exclude": ["node_modules/**"]
}