@regressionproof/jest-reporter 0.5.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ const snapshotter_1 = require("@regressionproof/snapshotter");
7
7
  const loadConfig_js_1 = require("./config/loadConfig.js");
8
8
  const SpruceError_js_1 = __importDefault(require("./errors/SpruceError.js"));
9
9
  const transformResults_js_1 = require("./transformers/transformResults.js");
10
+ const captureTypeErrors_js_1 = require("./utilities/captureTypeErrors.js");
10
11
  const version_js_1 = require("./utilities/version.js");
11
12
  class RegressionProofReporter {
12
13
  constructor(_globalConfig, _reporterConfig) {
@@ -32,7 +33,14 @@ class RegressionProofReporter {
32
33
  });
33
34
  }
34
35
  const testResults = (0, transformResults_js_1.transformResults)(results, this.cwd);
36
+ const typeErrors = (0, captureTypeErrors_js_1.captureTypeErrors)(this.cwd);
37
+ if (typeErrors.length > 0) {
38
+ testResults.typeErrors = typeErrors;
39
+ }
35
40
  console.log(`[RegressionProof] ${testResults.summary.passedTests}/${testResults.summary.totalTests} tests passed`);
41
+ if (typeErrors.length > 0) {
42
+ console.log(`[RegressionProof] ${typeErrors.length} type error(s) found`);
43
+ }
36
44
  try {
37
45
  const committed = await (0, snapshotter_1.snapshot)({
38
46
  sourcePath: this.cwd,
@@ -11,6 +11,7 @@ import { snapshot } from '@regressionproof/snapshotter';
11
11
  import { loadConfig, detectProjectName } from './config/loadConfig.js.js';
12
12
  import SpruceError from './errors/SpruceError.js.js';
13
13
  import { transformResults } from './transformers/transformResults.js.js';
14
+ import { captureTypeErrors } from './utilities/captureTypeErrors.js.js';
14
15
  import { getPackageVersion } from './utilities/version.js.js';
15
16
  export default class RegressionProofReporter {
16
17
  constructor(_globalConfig, _reporterConfig) {
@@ -38,7 +39,14 @@ export default class RegressionProofReporter {
38
39
  });
39
40
  }
40
41
  const testResults = transformResults(results, this.cwd);
42
+ const typeErrors = captureTypeErrors(this.cwd);
43
+ if (typeErrors.length > 0) {
44
+ testResults.typeErrors = typeErrors;
45
+ }
41
46
  console.log(`[RegressionProof] ${testResults.summary.passedTests}/${testResults.summary.totalTests} tests passed`);
47
+ if (typeErrors.length > 0) {
48
+ console.log(`[RegressionProof] ${typeErrors.length} type error(s) found`);
49
+ }
42
50
  try {
43
51
  const committed = yield snapshot({
44
52
  sourcePath: this.cwd,
@@ -0,0 +1,2 @@
1
+ import type { TypeCheckError } from '@regressionproof/snapshotter';
2
+ export declare function captureTypeErrors(projectRoot: string): TypeCheckError[];
@@ -0,0 +1,43 @@
1
+ import { execSync } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import path from 'path';
4
+ export function captureTypeErrors(projectRoot) {
5
+ const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
6
+ if (!existsSync(tsconfigPath)) {
7
+ return [];
8
+ }
9
+ try {
10
+ execSync('tsc --noEmit --pretty false', {
11
+ cwd: projectRoot,
12
+ encoding: 'utf-8',
13
+ stdio: ['pipe', 'pipe', 'pipe'],
14
+ });
15
+ return [];
16
+ }
17
+ catch (err) {
18
+ const error = err;
19
+ const output = error.stdout || error.stderr || '';
20
+ return parseTypeScriptErrors(output, projectRoot);
21
+ }
22
+ }
23
+ function parseTypeScriptErrors(output, projectRoot) {
24
+ const errors = [];
25
+ const lines = output.split('\n');
26
+ for (const line of lines) {
27
+ const match = line.match(/^(.+)\((\d+),(\d+)\):\s+error\s+(TS\d+):\s+(.+)$/);
28
+ if (match) {
29
+ const [, filePath, lineStr, colStr, code, message] = match;
30
+ const relativePath = path.isAbsolute(filePath)
31
+ ? path.relative(projectRoot, filePath)
32
+ : filePath;
33
+ errors.push({
34
+ file: relativePath,
35
+ line: parseInt(lineStr, 10),
36
+ column: parseInt(colStr, 10),
37
+ code,
38
+ message,
39
+ });
40
+ }
41
+ }
42
+ return errors;
43
+ }
@@ -0,0 +1,2 @@
1
+ import type { TypeCheckError } from '@regressionproof/snapshotter';
2
+ export declare function captureTypeErrors(projectRoot: string): TypeCheckError[];
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.captureTypeErrors = captureTypeErrors;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
10
+ function captureTypeErrors(projectRoot) {
11
+ const tsconfigPath = path_1.default.join(projectRoot, 'tsconfig.json');
12
+ if (!(0, fs_1.existsSync)(tsconfigPath)) {
13
+ return [];
14
+ }
15
+ try {
16
+ (0, child_process_1.execSync)('tsc --noEmit --pretty false', {
17
+ cwd: projectRoot,
18
+ encoding: 'utf-8',
19
+ stdio: ['pipe', 'pipe', 'pipe'],
20
+ });
21
+ return [];
22
+ }
23
+ catch (err) {
24
+ const error = err;
25
+ const output = error.stdout || error.stderr || '';
26
+ return parseTypeScriptErrors(output, projectRoot);
27
+ }
28
+ }
29
+ function parseTypeScriptErrors(output, projectRoot) {
30
+ const errors = [];
31
+ const lines = output.split('\n');
32
+ for (const line of lines) {
33
+ const match = line.match(/^(.+)\((\d+),(\d+)\):\s+error\s+(TS\d+):\s+(.+)$/);
34
+ if (match) {
35
+ const [, filePath, lineStr, colStr, code, message] = match;
36
+ const relativePath = path_1.default.isAbsolute(filePath)
37
+ ? path_1.default.relative(projectRoot, filePath)
38
+ : filePath;
39
+ errors.push({
40
+ file: relativePath,
41
+ line: parseInt(lineStr, 10),
42
+ column: parseInt(colStr, 10),
43
+ code,
44
+ message,
45
+ });
46
+ }
47
+ }
48
+ return errors;
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regressionproof/jest-reporter",
3
- "version": "0.5.6",
3
+ "version": "0.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,7 +35,7 @@
35
35
  "watch.tsc": "tsc -w"
36
36
  },
37
37
  "dependencies": {
38
- "@regressionproof/snapshotter": "^0.5.6",
38
+ "@regressionproof/snapshotter": "^0.6.0",
39
39
  "@sprucelabs/error": "^8.1.2",
40
40
  "@sprucelabs/schema": "^33.1.3",
41
41
  "@sprucelabs/spruce-core-schemas": "^42.1.3",
@@ -82,5 +82,5 @@
82
82
  "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
83
83
  }
84
84
  },
85
- "gitHead": "88d242a7078bcc4222757701713e96116fab97db"
85
+ "gitHead": "8ee36b6a7c70f4e675abc5205a5815266be1cdab"
86
86
  }