@regressionproof/jest-reporter 0.3.8 → 0.4.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.
Files changed (30) hide show
  1. package/build/.spruce/errors/errors.types.d.ts +21 -0
  2. package/build/.spruce/errors/errors.types.js +2 -0
  3. package/build/.spruce/errors/options.types.d.ts +7 -0
  4. package/build/.spruce/errors/options.types.js +2 -0
  5. package/build/.spruce/errors/regressionproofJestReporter/projectNotInitialized.schema.d.ts +3 -0
  6. package/build/.spruce/errors/regressionproofJestReporter/projectNotInitialized.schema.js +18 -0
  7. package/build/.spruce/schemas/fields/fieldClassMap.d.ts +2 -0
  8. package/build/.spruce/schemas/fields/fieldClassMap.js +4 -0
  9. package/build/.spruce/schemas/fields/fields.types.d.ts +1 -0
  10. package/build/.spruce/schemas/fields/fields.types.js +2 -0
  11. package/build/.spruce/settings.json +3 -1
  12. package/build/RegressionProofReporter.js +10 -2
  13. package/build/config/loadConfig.d.ts +1 -0
  14. package/build/config/loadConfig.js +1 -0
  15. package/build/errors/SpruceError.d.ts +6 -0
  16. package/build/errors/SpruceError.js +25 -0
  17. package/build/errors/projectNotInitialized.builder.d.ts +11 -0
  18. package/build/errors/projectNotInitialized.builder.js +13 -0
  19. package/build/esm/.spruce/errors/errors.types.d.ts +21 -0
  20. package/build/esm/.spruce/errors/errors.types.js +1 -0
  21. package/build/esm/.spruce/errors/options.types.d.ts +7 -0
  22. package/build/esm/.spruce/errors/options.types.js +1 -0
  23. package/build/esm/RegressionProofReporter.js +9 -3
  24. package/build/esm/config/loadConfig.d.ts +1 -0
  25. package/build/esm/config/loadConfig.js +1 -1
  26. package/build/esm/errors/SpruceError.d.ts +6 -0
  27. package/build/esm/errors/SpruceError.js +19 -0
  28. package/build/esm/errors/projectNotInitialized.builder.d.ts +11 -0
  29. package/build/esm/errors/projectNotInitialized.builder.js +11 -0
  30. package/package.json +7 -3
@@ -0,0 +1,21 @@
1
+ import { default as SchemaEntity } from '@sprucelabs/schema';
2
+ import * as SpruceSchema from '@sprucelabs/schema';
3
+ export declare namespace SpruceErrors.RegressionproofJestReporter {
4
+ interface ProjectNotInitialized {
5
+ 'projectName': string;
6
+ }
7
+ interface ProjectNotInitializedSchema extends SpruceSchema.Schema {
8
+ id: 'projectNotInitialized';
9
+ namespace: 'RegressionproofJestReporter';
10
+ name: 'Project not initialized';
11
+ fields: {
12
+ /** . */
13
+ 'projectName': {
14
+ type: 'text';
15
+ isRequired: true;
16
+ options: undefined;
17
+ };
18
+ };
19
+ }
20
+ type ProjectNotInitializedEntity = SchemaEntity<SpruceErrors.RegressionproofJestReporter.ProjectNotInitializedSchema>;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { SpruceErrors } from "./errors.types";
2
+ import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
3
+ export interface ProjectNotInitializedErrorOptions extends SpruceErrors.RegressionproofJestReporter.ProjectNotInitialized, ISpruceErrorOptions {
4
+ code: 'PROJECT_NOT_INITIALIZED';
5
+ }
6
+ type ErrorOptions = ProjectNotInitializedErrorOptions;
7
+ export default ErrorOptions;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { SpruceErrors } from '../errors.types';
2
+ declare const projectNotInitializedSchema: SpruceErrors.RegressionproofJestReporter.ProjectNotInitializedSchema;
3
+ export default projectNotInitializedSchema;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ const projectNotInitializedSchema = {
5
+ id: 'projectNotInitialized',
6
+ namespace: 'RegressionproofJestReporter',
7
+ name: 'Project not initialized',
8
+ fields: {
9
+ /** . */
10
+ 'projectName': {
11
+ type: 'text',
12
+ isRequired: true,
13
+ options: undefined
14
+ },
15
+ }
16
+ };
17
+ schema_1.SchemaRegistry.getInstance().trackSchema(projectNotInitializedSchema);
18
+ exports.default = projectNotInitializedSchema;
@@ -0,0 +1,2 @@
1
+ import { fieldClassMap } from '@sprucelabs/schema';
2
+ export default fieldClassMap;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ exports.default = schema_1.fieldClassMap;
@@ -0,0 +1 @@
1
+ export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap } from '@sprucelabs/schema';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,7 +6,9 @@
6
6
  "skill"
7
7
  ],
8
8
  "installed": [
9
- "test"
9
+ "test",
10
+ "schema",
11
+ "error"
10
12
  ],
11
13
  "writer": {
12
14
  "skipped": [
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const snapshotter_1 = require("@regressionproof/snapshotter");
4
7
  const loadConfig_js_1 = require("./config/loadConfig.js");
8
+ const SpruceError_js_1 = __importDefault(require("./errors/SpruceError.js"));
5
9
  const transformResults_js_1 = require("./transformers/transformResults.js");
6
10
  class RegressionProofReporter {
7
11
  constructor(_globalConfig, _reporterConfig) {
@@ -18,8 +22,12 @@ class RegressionProofReporter {
18
22
  return;
19
23
  }
20
24
  if (!config) {
21
- console.log('[RegressionProof] No config found. Run `regressionproof init` to set up.');
22
- return;
25
+ const projectName = (0, loadConfig_js_1.detectProjectName)(this.cwd) ?? 'unknown';
26
+ throw new SpruceError_js_1.default({
27
+ code: 'PROJECT_NOT_INITIALIZED',
28
+ projectName,
29
+ friendlyMessage: 'RegressionProof.ai not initialized. Ask the project owner for an invite token, then run `npx regressionproof invite accept <token>`.',
30
+ });
23
31
  }
24
32
  const testResults = (0, transformResults_js_1.transformResults)(results, this.cwd);
25
33
  console.log(`[RegressionProof] ${testResults.summary.passedTests}/${testResults.summary.totalTests} tests passed`);
@@ -1,4 +1,5 @@
1
1
  export declare function loadConfig(cwd: string): ReporterConfig | null;
2
+ export declare function detectProjectName(cwd: string): string | null;
2
3
  export interface ReporterConfig {
3
4
  projectName: string;
4
5
  mirrorPath: string;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadConfig = loadConfig;
7
+ exports.detectProjectName = detectProjectName;
7
8
  const child_process_1 = require("child_process");
8
9
  const fs_1 = __importDefault(require("fs"));
9
10
  const os_1 = __importDefault(require("os"));
@@ -0,0 +1,6 @@
1
+ import BaseSpruceError from '@sprucelabs/error';
2
+ import ErrorOptions from './../.spruce/errors/options.types';
3
+ export default class SpruceError extends BaseSpruceError<ErrorOptions> {
4
+ /** an easy to understand version of the errors */
5
+ friendlyMessage(): string;
6
+ }
@@ -0,0 +1,25 @@
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
+ const error_1 = __importDefault(require("@sprucelabs/error"));
7
+ class SpruceError extends error_1.default {
8
+ /** an easy to understand version of the errors */
9
+ friendlyMessage() {
10
+ const { options } = this;
11
+ let message;
12
+ switch (options?.code) {
13
+ case 'PROJECT_NOT_INITIALIZED':
14
+ message = 'A Project not initialized just happened!';
15
+ break;
16
+ default:
17
+ message = super.friendlyMessage();
18
+ }
19
+ const fullMessage = options.friendlyMessage
20
+ ? options.friendlyMessage
21
+ : message;
22
+ return fullMessage;
23
+ }
24
+ }
25
+ exports.default = SpruceError;
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {
5
+ projectName: {
6
+ type: "text";
7
+ isRequired: true;
8
+ };
9
+ };
10
+ };
11
+ export default _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ exports.default = (0, schema_1.buildErrorSchema)({
5
+ id: 'projectNotInitialized',
6
+ name: 'Project not initialized',
7
+ fields: {
8
+ projectName: {
9
+ type: 'text',
10
+ isRequired: true,
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,21 @@
1
+ import { default as SchemaEntity } from '@sprucelabs/schema';
2
+ import * as SpruceSchema from '@sprucelabs/schema';
3
+ export declare namespace SpruceErrors.RegressionproofJestReporter {
4
+ interface ProjectNotInitialized {
5
+ 'projectName': string;
6
+ }
7
+ interface ProjectNotInitializedSchema extends SpruceSchema.Schema {
8
+ id: 'projectNotInitialized';
9
+ namespace: 'RegressionproofJestReporter';
10
+ name: 'Project not initialized';
11
+ fields: {
12
+ /** . */
13
+ 'projectName': {
14
+ type: 'text';
15
+ isRequired: true;
16
+ options: undefined;
17
+ };
18
+ };
19
+ }
20
+ type ProjectNotInitializedEntity = SchemaEntity<SpruceErrors.RegressionproofJestReporter.ProjectNotInitializedSchema>;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { SpruceErrors } from "./errors.types";
2
+ import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
3
+ export interface ProjectNotInitializedErrorOptions extends SpruceErrors.RegressionproofJestReporter.ProjectNotInitialized, ISpruceErrorOptions {
4
+ code: 'PROJECT_NOT_INITIALIZED';
5
+ }
6
+ type ErrorOptions = ProjectNotInitializedErrorOptions;
7
+ export default ErrorOptions;
@@ -0,0 +1 @@
1
+ export {};
@@ -8,7 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { snapshot } from '@regressionproof/snapshotter';
11
- import { loadConfig } from './config/loadConfig.js.js';
11
+ import { loadConfig, detectProjectName } from './config/loadConfig.js.js';
12
+ import SpruceError from './errors/SpruceError.js.js';
12
13
  import { transformResults } from './transformers/transformResults.js.js';
13
14
  export default class RegressionProofReporter {
14
15
  constructor(_globalConfig, _reporterConfig) {
@@ -20,14 +21,19 @@ export default class RegressionProofReporter {
20
21
  onTestCaseResult(_test, _testCaseResult) { }
21
22
  onRunComplete(_testContexts, results) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
24
+ var _a;
23
25
  const config = loadConfig(this.cwd);
24
26
  if (this.isCi) {
25
27
  console.log('[RegressionProof] CI detected; skipping snapshot');
26
28
  return;
27
29
  }
28
30
  if (!config) {
29
- console.log('[RegressionProof] No config found. Run `regressionproof init` to set up.');
30
- return;
31
+ const projectName = (_a = detectProjectName(this.cwd)) !== null && _a !== void 0 ? _a : 'unknown';
32
+ throw new SpruceError({
33
+ code: 'PROJECT_NOT_INITIALIZED',
34
+ projectName,
35
+ friendlyMessage: 'RegressionProof.ai not initialized. Ask the project owner for an invite token, then run `npx regressionproof invite accept <token>`.',
36
+ });
31
37
  }
32
38
  const testResults = transformResults(results, this.cwd);
33
39
  console.log(`[RegressionProof] ${testResults.summary.passedTests}/${testResults.summary.totalTests} tests passed`);
@@ -1,4 +1,5 @@
1
1
  export declare function loadConfig(cwd: string): ReporterConfig | null;
2
+ export declare function detectProjectName(cwd: string): string | null;
2
3
  export interface ReporterConfig {
3
4
  projectName: string;
4
5
  mirrorPath: string;
@@ -22,7 +22,7 @@ export function loadConfig(cwd) {
22
22
  },
23
23
  };
24
24
  }
25
- function detectProjectName(cwd) {
25
+ export function detectProjectName(cwd) {
26
26
  const localConfigPath = path.join(cwd, '.regressionproof.json');
27
27
  if (fs.existsSync(localConfigPath)) {
28
28
  const localConfig = JSON.parse(fs.readFileSync(localConfigPath, 'utf-8'));
@@ -0,0 +1,6 @@
1
+ import BaseSpruceError from '@sprucelabs/error';
2
+ import ErrorOptions from './../.spruce/errors/options.types';
3
+ export default class SpruceError extends BaseSpruceError<ErrorOptions> {
4
+ /** an easy to understand version of the errors */
5
+ friendlyMessage(): string;
6
+ }
@@ -0,0 +1,19 @@
1
+ import BaseSpruceError from '@sprucelabs/error';
2
+ export default class SpruceError extends BaseSpruceError {
3
+ /** an easy to understand version of the errors */
4
+ friendlyMessage() {
5
+ const { options } = this;
6
+ let message;
7
+ switch (options === null || options === void 0 ? void 0 : options.code) {
8
+ case 'PROJECT_NOT_INITIALIZED':
9
+ message = 'A Project not initialized just happened!';
10
+ break;
11
+ default:
12
+ message = super.friendlyMessage();
13
+ }
14
+ const fullMessage = options.friendlyMessage
15
+ ? options.friendlyMessage
16
+ : message;
17
+ return fullMessage;
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {
5
+ projectName: {
6
+ type: "text";
7
+ isRequired: true;
8
+ };
9
+ };
10
+ };
11
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema';
2
+ export default buildErrorSchema({
3
+ id: 'projectNotInitialized',
4
+ name: 'Project not initialized',
5
+ fields: {
6
+ projectName: {
7
+ type: 'text',
8
+ isRequired: true,
9
+ },
10
+ },
11
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regressionproof/jest-reporter",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,7 +35,11 @@
35
35
  "watch.tsc": "tsc -w"
36
36
  },
37
37
  "dependencies": {
38
- "@regressionproof/snapshotter": "^0.3.8"
38
+ "@regressionproof/snapshotter": "^0.4.0",
39
+ "@sprucelabs/error": "^8.1.2",
40
+ "@sprucelabs/schema": "^33.1.3",
41
+ "@sprucelabs/spruce-core-schemas": "^42.1.3",
42
+ "@sprucelabs/spruce-skill-utils": "^34.0.3"
39
43
  },
40
44
  "devDependencies": {
41
45
  "@jest/reporters": "^30.2.0",
@@ -78,5 +82,5 @@
78
82
  "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
79
83
  }
80
84
  },
81
- "gitHead": "b59db28cb04d4cf306b248c7816fd2b10a30f326"
85
+ "gitHead": "dc7c7eaa3342fcb4fdfae1d3c11a69b7e08dace4"
82
86
  }