@approval-tests/approvals 7.5.9 → 7.5.11
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.
- package/lib/Approvals.d.ts +1 -1
- package/lib/Approvals.js +4 -1
- package/lib/Approvals.ts +3 -1
- package/lib/Providers/Jest/JestApprovals.js +3 -0
- package/lib/Providers/Jest/JestApprovals.ts +2 -0
- package/lib/Providers/Jest/JestNamer.js +2 -2
- package/lib/Providers/Jest/JestNamer.ts +1 -1
- package/lib/Providers/Jest/JestReporter.js +6 -3
- package/lib/Providers/Jest/JestReporter.ts +5 -2
- package/lib/Providers/Mocha/MochaApprovals.js +9 -2
- package/lib/Providers/Mocha/MochaApprovals.ts +5 -1
- package/lib/Providers/Mocha/MochaNamer.d.ts +1 -1
- package/lib/Providers/Mocha/MochaNamer.ts +1 -1
- package/lib/Providers/OptionalFramework.d.ts +1 -0
- package/lib/Providers/OptionalFramework.js +15 -0
- package/lib/Providers/OptionalFramework.ts +11 -0
- package/lib/Providers/Vitest/VitestApprovals.js +3 -0
- package/lib/Providers/Vitest/VitestApprovals.ts +2 -0
- package/lib/Providers/Vitest/VitestReporter.js +4 -1
- package/lib/Providers/Vitest/VitestReporter.ts +3 -1
- package/lib/Writers/BinaryWriter.js +14 -6
- package/lib/Writers/BinaryWriter.ts +14 -3
- package/package.json +30 -14
- package/readme.md +8 -4
package/lib/Approvals.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export declare function verifyAsJSONAndScrub(dirName: string, testName: string,
|
|
|
94
94
|
/**
|
|
95
95
|
* This allows you to take full control of naming and writing files before verifying.
|
|
96
96
|
*
|
|
97
|
-
* For an example that we use to generate the docs within the readme, check out the [test/readmeTests.mts](test/readmeTests.mts) in this project.
|
|
97
|
+
* For an example that we use to generate the docs within the readme, check out the [test/mocha/readmeTests.mts](test/mocha/readmeTests.mts) in this project.
|
|
98
98
|
*
|
|
99
99
|
* @param {Object} namer
|
|
100
100
|
* @param {Object} writer
|
package/lib/Approvals.js
CHANGED
|
@@ -67,6 +67,7 @@ const AUtils_1 = require("./AUtils");
|
|
|
67
67
|
// they won't get a helpful error. So we put this in there - just in case"
|
|
68
68
|
const MochaNamer_1 = require("./Providers/Mocha/MochaNamer");
|
|
69
69
|
const BeforeEachVerifierBase_1 = require("./Providers/BeforeEachVerifierBase");
|
|
70
|
+
const OptionalFramework_1 = require("./Providers/OptionalFramework");
|
|
70
71
|
if (typeof beforeEach === "function") {
|
|
71
72
|
beforeEach(function () {
|
|
72
73
|
if (!this) {
|
|
@@ -125,6 +126,8 @@ function getConfig(overrideOptions) {
|
|
|
125
126
|
* @param {*} optionalBaseDir - An optional folder to save approval files to.
|
|
126
127
|
*/
|
|
127
128
|
function mocha(optionalBaseDir) {
|
|
129
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("mocha"))
|
|
130
|
+
return module.exports;
|
|
128
131
|
// if not providing a base dir, fallback to the current calling code's directory
|
|
129
132
|
if (!optionalBaseDir) {
|
|
130
133
|
let fileName = (0, callsite_1.default)()[1].getFileName();
|
|
@@ -263,7 +266,7 @@ function verifyAsJSONAndScrub(dirName, testName, data, scrubber, optionsOverride
|
|
|
263
266
|
/**
|
|
264
267
|
* This allows you to take full control of naming and writing files before verifying.
|
|
265
268
|
*
|
|
266
|
-
* For an example that we use to generate the docs within the readme, check out the [test/readmeTests.mts](test/readmeTests.mts) in this project.
|
|
269
|
+
* For an example that we use to generate the docs within the readme, check out the [test/mocha/readmeTests.mts](test/mocha/readmeTests.mts) in this project.
|
|
267
270
|
*
|
|
268
271
|
* @param {Object} namer
|
|
269
272
|
* @param {Object} writer
|
package/lib/Approvals.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { stringifyKeysInOrder } from "./AUtils";
|
|
|
26
26
|
import { MochaNamer } from "./Providers/Mocha/MochaNamer";
|
|
27
27
|
|
|
28
28
|
import { beforeEachVerifierBase } from "./Providers/BeforeEachVerifierBase";
|
|
29
|
+
import { isFrameworkAvailable } from "./Providers/OptionalFramework";
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Contains some helpful and util scrubbers that can be used for scrubbing data before saving to a received file.
|
|
@@ -96,6 +97,7 @@ export function getConfig(overrideOptions?: cfg.Config): cfg.Config {
|
|
|
96
97
|
*/
|
|
97
98
|
|
|
98
99
|
export function mocha(optionalBaseDir?: string): typeof module.exports {
|
|
100
|
+
if (!isFrameworkAvailable("mocha")) return module.exports;
|
|
99
101
|
// if not providing a base dir, fallback to the current calling code's directory
|
|
100
102
|
if (!optionalBaseDir) {
|
|
101
103
|
let fileName = callsite()[1].getFileName();
|
|
@@ -293,7 +295,7 @@ export function verifyAsJSONAndScrub(
|
|
|
293
295
|
/**
|
|
294
296
|
* This allows you to take full control of naming and writing files before verifying.
|
|
295
297
|
*
|
|
296
|
-
* For an example that we use to generate the docs within the readme, check out the [test/readmeTests.mts](test/readmeTests.mts) in this project.
|
|
298
|
+
* For an example that we use to generate the docs within the readme, check out the [test/mocha/readmeTests.mts](test/mocha/readmeTests.mts) in this project.
|
|
297
299
|
*
|
|
298
300
|
* @param {Object} namer
|
|
299
301
|
* @param {Object} writer
|
|
@@ -52,7 +52,10 @@ const Options_1 = require("../../Core/Options");
|
|
|
52
52
|
const JestNamer_1 = require("./JestNamer");
|
|
53
53
|
const StringWriter_1 = require("../../StringWriter");
|
|
54
54
|
const approvals = __importStar(require("../../Approvals"));
|
|
55
|
+
const OptionalFramework_1 = require("../OptionalFramework");
|
|
55
56
|
function verify(sut, options) {
|
|
57
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("jest"))
|
|
58
|
+
return;
|
|
56
59
|
options = options || new Options_1.Options();
|
|
57
60
|
options = options.withNamer((0, JestNamer_1.getJestNamer)());
|
|
58
61
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -15,8 +15,10 @@ import { getJestNamer } from "./JestNamer";
|
|
|
15
15
|
|
|
16
16
|
import { StringWriter } from "../../StringWriter";
|
|
17
17
|
import * as approvals from "../../Approvals";
|
|
18
|
+
import { isFrameworkAvailable } from "../OptionalFramework";
|
|
18
19
|
|
|
19
20
|
export function verify(sut: any, options?: Options): void {
|
|
21
|
+
if (!isFrameworkAvailable("jest")) return;
|
|
20
22
|
options = options || new Options();
|
|
21
23
|
options = options.withNamer(getJestNamer());
|
|
22
24
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getJestNamer = getJestNamer;
|
|
7
|
-
const globals_1 = require("@jest/globals");
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const Namer_1 = require("../../Namer");
|
|
10
9
|
const Namer_2 = require("../../Core/Namer");
|
|
11
10
|
function getJestNamer() {
|
|
12
|
-
const
|
|
11
|
+
const { expect } = require("@jest/globals");
|
|
12
|
+
const state = expect.getState();
|
|
13
13
|
const file = path_1.default.parse(state.testPath);
|
|
14
14
|
const testPath = file.dir;
|
|
15
15
|
const testFileName = file.name;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { expect } from "@jest/globals";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { Namer } from "../../Namer";
|
|
4
3
|
import { convertToFilename } from "../../Core/Namer";
|
|
5
4
|
|
|
6
5
|
export function getJestNamer(): Namer {
|
|
6
|
+
const { expect } = require("@jest/globals") as typeof import("@jest/globals");
|
|
7
7
|
const state = expect.getState();
|
|
8
8
|
const file = path.parse(state.testPath as string);
|
|
9
9
|
const testPath = file.dir;
|
|
@@ -4,19 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.JestReporter = void 0;
|
|
7
|
-
const
|
|
7
|
+
const OptionalFramework_1 = require("../OptionalFramework");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
class JestReporter {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.name = "JestReporter";
|
|
12
12
|
}
|
|
13
13
|
canReportOn(_fileName) {
|
|
14
|
-
return
|
|
14
|
+
return (0, OptionalFramework_1.isFrameworkAvailable)("jest");
|
|
15
15
|
}
|
|
16
16
|
report(approvedFilePath, receivedFilePath, _) {
|
|
17
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("jest"))
|
|
18
|
+
return;
|
|
19
|
+
const { expect } = require("@jest/globals");
|
|
17
20
|
const approvedText = fs_1.default.readFileSync(approvedFilePath).toString();
|
|
18
21
|
const receivedText = fs_1.default.readFileSync(receivedFilePath).toString();
|
|
19
|
-
|
|
22
|
+
expect(receivedText).toBe(approvedText);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
exports.JestReporter = JestReporter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFrameworkAvailable } from "../OptionalFramework";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { Config } from "../../config";
|
|
4
4
|
import { Reporter } from "../../Core/Reporter";
|
|
@@ -7,7 +7,7 @@ export class JestReporter implements Reporter {
|
|
|
7
7
|
name: string = "JestReporter";
|
|
8
8
|
|
|
9
9
|
canReportOn(_fileName: string) {
|
|
10
|
-
return
|
|
10
|
+
return isFrameworkAvailable("jest");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
report(
|
|
@@ -15,6 +15,9 @@ export class JestReporter implements Reporter {
|
|
|
15
15
|
receivedFilePath: string,
|
|
16
16
|
_: Partial<Config>,
|
|
17
17
|
) {
|
|
18
|
+
if (!isFrameworkAvailable("jest")) return;
|
|
19
|
+
const { expect } =
|
|
20
|
+
require("@jest/globals") as typeof import("@jest/globals");
|
|
18
21
|
const approvedText = fs.readFileSync(approvedFilePath).toString();
|
|
19
22
|
const receivedText = fs.readFileSync(receivedFilePath).toString();
|
|
20
23
|
expect(receivedText).toBe(approvedText);
|
|
@@ -56,12 +56,15 @@ const Printers_1 = require("../../Utilities/Printers");
|
|
|
56
56
|
*/
|
|
57
57
|
const Options_1 = require("../../Core/Options");
|
|
58
58
|
const MochaNamer_1 = require("./MochaNamer");
|
|
59
|
-
const
|
|
59
|
+
const OptionalFramework_1 = require("../OptionalFramework");
|
|
60
60
|
const StringWriter_1 = __importDefault(require("../../StringWriter"));
|
|
61
61
|
const approvals = __importStar(require("../../Approvals"));
|
|
62
62
|
let mochaTest = null;
|
|
63
63
|
function it2(label, test) {
|
|
64
|
-
|
|
64
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("mocha"))
|
|
65
|
+
return;
|
|
66
|
+
const mocha = require("mocha");
|
|
67
|
+
mocha.it(label, function () {
|
|
65
68
|
mochaTest = this;
|
|
66
69
|
console.log("Mocha Test: ", mochaTest.test.name);
|
|
67
70
|
test();
|
|
@@ -69,12 +72,16 @@ function it2(label, test) {
|
|
|
69
72
|
}
|
|
70
73
|
let namer;
|
|
71
74
|
function setNamer(that) {
|
|
75
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("mocha"))
|
|
76
|
+
return;
|
|
72
77
|
namer = (0, MochaNamer_1.getMochaNamer)(that.currentTest);
|
|
73
78
|
}
|
|
74
79
|
function getNamer() {
|
|
75
80
|
return namer;
|
|
76
81
|
}
|
|
77
82
|
function verify(sut, options) {
|
|
83
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("mocha"))
|
|
84
|
+
return;
|
|
78
85
|
options = options || new Options_1.Options();
|
|
79
86
|
options = options.withNamer(getNamer());
|
|
80
87
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -12,7 +12,7 @@ import { printArray, printJson } from "../../Utilities/Printers";
|
|
|
12
12
|
*/
|
|
13
13
|
import { Options } from "../../Core/Options";
|
|
14
14
|
import { getMochaNamer } from "./MochaNamer";
|
|
15
|
-
import
|
|
15
|
+
import { isFrameworkAvailable } from "../OptionalFramework";
|
|
16
16
|
|
|
17
17
|
import StringWriter from "../../StringWriter";
|
|
18
18
|
|
|
@@ -22,6 +22,8 @@ import { Namer } from "../../Core/Namer";
|
|
|
22
22
|
let mochaTest: any = null;
|
|
23
23
|
|
|
24
24
|
export function it2(label: string, test: () => void): void {
|
|
25
|
+
if (!isFrameworkAvailable("mocha")) return;
|
|
26
|
+
const mocha = require("mocha") as typeof import("mocha");
|
|
25
27
|
mocha.it(label, function (this: any) {
|
|
26
28
|
mochaTest = this;
|
|
27
29
|
console.log("Mocha Test: ", mochaTest.test.name);
|
|
@@ -32,6 +34,7 @@ export function it2(label: string, test: () => void): void {
|
|
|
32
34
|
let namer: Namer;
|
|
33
35
|
|
|
34
36
|
export function setNamer(that: any): void {
|
|
37
|
+
if (!isFrameworkAvailable("mocha")) return;
|
|
35
38
|
namer = getMochaNamer(that.currentTest);
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -40,6 +43,7 @@ export function getNamer(): Namer {
|
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
export function verify(sut: any, options?: Options): void {
|
|
46
|
+
if (!isFrameworkAvailable("mocha")) return;
|
|
43
47
|
options = options || new Options();
|
|
44
48
|
options = options.withNamer(getNamer());
|
|
45
49
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFrameworkAvailable(framework: string): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFrameworkAvailable = isFrameworkAvailable;
|
|
4
|
+
function isFrameworkAvailable(framework) {
|
|
5
|
+
try {
|
|
6
|
+
require.resolve(framework);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error.code !== "MODULE_NOT_FOUND") {
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -41,7 +41,10 @@ const Options_1 = require("../../Core/Options");
|
|
|
41
41
|
const VitestNamer_1 = require("./VitestNamer");
|
|
42
42
|
const StringWriter_1 = require("../../StringWriter");
|
|
43
43
|
const approvals = __importStar(require("../../Approvals"));
|
|
44
|
+
const OptionalFramework_1 = require("../OptionalFramework");
|
|
44
45
|
function verify(sut, options) {
|
|
46
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("vitest"))
|
|
47
|
+
return;
|
|
45
48
|
options = options || new Options_1.Options();
|
|
46
49
|
options = options.withNamer((0, VitestNamer_1.getVitestNamer)());
|
|
47
50
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -4,8 +4,10 @@ import { getVitestNamer } from "./VitestNamer";
|
|
|
4
4
|
|
|
5
5
|
import { StringWriter } from "../../StringWriter";
|
|
6
6
|
import * as approvals from "../../Approvals";
|
|
7
|
+
import { isFrameworkAvailable } from "../OptionalFramework";
|
|
7
8
|
|
|
8
9
|
export function verify(sut: any, options?: Options): void {
|
|
10
|
+
if (!isFrameworkAvailable("vitest")) return;
|
|
9
11
|
options = options || new Options();
|
|
10
12
|
options = options.withNamer(getVitestNamer());
|
|
11
13
|
const config = options.getConfig(approvals.getConfig());
|
|
@@ -5,14 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.VitestReporter = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const OptionalFramework_1 = require("../OptionalFramework");
|
|
8
9
|
class VitestReporter {
|
|
9
10
|
constructor() {
|
|
10
11
|
this.name = "VitestReporter";
|
|
11
12
|
}
|
|
12
13
|
canReportOn(_fileName) {
|
|
13
|
-
return
|
|
14
|
+
return (0, OptionalFramework_1.isFrameworkAvailable)("vitest");
|
|
14
15
|
}
|
|
15
16
|
report(approvedFilePath, receivedFilePath, _) {
|
|
17
|
+
if (!(0, OptionalFramework_1.isFrameworkAvailable)("vitest"))
|
|
18
|
+
return;
|
|
16
19
|
const approvedText = fs_1.default.readFileSync(approvedFilePath).toString();
|
|
17
20
|
const receivedText = fs_1.default.readFileSync(receivedFilePath).toString();
|
|
18
21
|
expect(receivedText).toBe(approvedText);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import { Config } from "../../config";
|
|
3
3
|
import { Reporter } from "../../Core/Reporter";
|
|
4
|
+
import { isFrameworkAvailable } from "../OptionalFramework";
|
|
4
5
|
|
|
5
6
|
declare const expect: (actual: unknown) => { toBe(expected: unknown): void };
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ export class VitestReporter implements Reporter {
|
|
|
8
9
|
name: string = "VitestReporter";
|
|
9
10
|
|
|
10
11
|
canReportOn(_fileName: string) {
|
|
11
|
-
return
|
|
12
|
+
return isFrameworkAvailable("vitest");
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
report(
|
|
@@ -16,6 +17,7 @@ export class VitestReporter implements Reporter {
|
|
|
16
17
|
receivedFilePath: string,
|
|
17
18
|
_: Partial<Config>,
|
|
18
19
|
) {
|
|
20
|
+
if (!isFrameworkAvailable("vitest")) return;
|
|
19
21
|
const approvedText = fs.readFileSync(approvedFilePath).toString();
|
|
20
22
|
const receivedText = fs.readFileSync(receivedFilePath).toString();
|
|
21
23
|
expect(receivedText).toBe(approvedText);
|
|
@@ -32,23 +32,31 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.BinaryWriter = void 0;
|
|
40
37
|
const fs = __importStar(require("fs"));
|
|
41
38
|
const path = __importStar(require("path"));
|
|
42
39
|
const mkdirp_1 = require("mkdirp");
|
|
43
|
-
const
|
|
40
|
+
const magic_bytes_js_1 = require("magic-bytes.js");
|
|
44
41
|
class BinaryWriter {
|
|
45
42
|
constructor(outputData) {
|
|
46
43
|
this.outputData = outputData;
|
|
47
44
|
}
|
|
48
45
|
getFileExtension() {
|
|
49
46
|
if (!this._ext) {
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
// Use the first signature match (for example, zip before jar/docx).
|
|
48
|
+
const extension = (0, magic_bytes_js_1.filetypeextension)(this.outputData)[0] || "blob";
|
|
49
|
+
// Keep existing JPEG and TIFF approval filenames compatible.
|
|
50
|
+
switch (extension) {
|
|
51
|
+
case "jpeg":
|
|
52
|
+
this._ext = "jpg";
|
|
53
|
+
break;
|
|
54
|
+
case "tiff":
|
|
55
|
+
this._ext = "tif";
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
this._ext = extension;
|
|
59
|
+
}
|
|
52
60
|
}
|
|
53
61
|
return this._ext;
|
|
54
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { sync } from "mkdirp";
|
|
4
|
-
import
|
|
4
|
+
import { filetypeextension } from "magic-bytes.js";
|
|
5
5
|
import { Writer } from "../Core/Writer";
|
|
6
6
|
|
|
7
7
|
export class BinaryWriter implements Writer {
|
|
@@ -14,8 +14,19 @@ export class BinaryWriter implements Writer {
|
|
|
14
14
|
|
|
15
15
|
getFileExtension(): string {
|
|
16
16
|
if (!this._ext) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Use the first signature match (for example, zip before jar/docx).
|
|
18
|
+
const extension = filetypeextension(this.outputData)[0] || "blob";
|
|
19
|
+
// Keep existing JPEG and TIFF approval filenames compatible.
|
|
20
|
+
switch (extension) {
|
|
21
|
+
case "jpeg":
|
|
22
|
+
this._ext = "jpg";
|
|
23
|
+
break;
|
|
24
|
+
case "tiff":
|
|
25
|
+
this._ext = "tif";
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
this._ext = extension;
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
31
|
return this._ext;
|
|
21
32
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"description": "Approval Tests Library - Capturing Human Intelligence",
|
|
7
|
-
"version": "7.5.
|
|
7
|
+
"version": "7.5.11",
|
|
8
8
|
"homepage": "http://approvaltests.com",
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Jason Jarrett",
|
|
@@ -39,12 +39,13 @@
|
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc",
|
|
42
|
-
"test": "
|
|
43
|
-
"vitest": "vitest
|
|
42
|
+
"test": "node scripts/test.cjs",
|
|
43
|
+
"vitest": "node scripts/test-isolated.cjs vitest",
|
|
44
44
|
"test2": "npm run mocha && npm run lint",
|
|
45
45
|
"lint": "eslint lib test",
|
|
46
|
-
"mocha": "mocha",
|
|
47
|
-
"coverage": "
|
|
46
|
+
"mocha": "node scripts/test-isolated.cjs mocha",
|
|
47
|
+
"coverage": "node scripts/test-isolated.cjs mocha --coverage",
|
|
48
|
+
"jest": "node scripts/test-isolated.cjs jest"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
51
|
"ansi-colors": "^4.1.3",
|
|
@@ -52,18 +53,16 @@
|
|
|
52
53
|
"callsite": "^1.0.0",
|
|
53
54
|
"diff": "^9.0.0",
|
|
54
55
|
"event-stream": "^4.0.1",
|
|
55
|
-
"file-type": "^12.4.2",
|
|
56
56
|
"glob": "^13.0.0",
|
|
57
|
-
"jest": "^30.0.0",
|
|
58
57
|
"js-yaml": "^5.1.0",
|
|
59
58
|
"lodash": "^4.17.21",
|
|
59
|
+
"magic-bytes.js": "^1.13.1",
|
|
60
60
|
"marked": "^18.0.14",
|
|
61
61
|
"marked-terminal-renderer": "^2.2.0",
|
|
62
62
|
"minimist": "^1.2.8",
|
|
63
63
|
"mkdirp": "^3.0.1",
|
|
64
64
|
"shelljs": "^0.10.0",
|
|
65
|
-
"temp": "^0.9.4"
|
|
66
|
-
"ts-jest": "^29.0.3"
|
|
65
|
+
"temp": "^0.9.4"
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
68
|
"@types/chai": "^5.0.1",
|
|
@@ -74,17 +73,13 @@
|
|
|
74
73
|
"chai": "^6.0.1",
|
|
75
74
|
"eslint": "^10.2.1",
|
|
76
75
|
"eslint-plugin-promise": "^7.2.1",
|
|
77
|
-
"jest-junit": "^17.0.0",
|
|
78
76
|
"jsdoc-to-markdown": "^9.1.1",
|
|
79
|
-
"mocha": "^12.0.2",
|
|
80
|
-
"mocha-multi-reporters": "^1.5.1",
|
|
81
77
|
"nyc": "^18.0.0",
|
|
82
78
|
"pre-commit": "^2.0.0",
|
|
83
79
|
"prettier": "^3.4.2",
|
|
84
80
|
"sinon": "^22.0.0",
|
|
85
81
|
"ts-node": "^10.9.1",
|
|
86
|
-
"typescript": "^6.0.2"
|
|
87
|
-
"vitest": "^5.0.1"
|
|
82
|
+
"typescript": "^6.0.2"
|
|
88
83
|
},
|
|
89
84
|
"keywords": [
|
|
90
85
|
"Approve",
|
|
@@ -96,5 +91,26 @@
|
|
|
96
91
|
"Testing",
|
|
97
92
|
"Verification",
|
|
98
93
|
"Verify"
|
|
94
|
+
],
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"jest": "^30.0.0",
|
|
97
|
+
"mocha": "^12.0.2",
|
|
98
|
+
"vitest": "^5.0.1"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"jest": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"mocha": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"vitest": {
|
|
108
|
+
"optional": true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"workspaces": [
|
|
112
|
+
"test/mocha",
|
|
113
|
+
"test/jest",
|
|
114
|
+
"test/vitest"
|
|
99
115
|
]
|
|
100
116
|
}
|
package/readme.md
CHANGED
|
@@ -69,6 +69,10 @@ What is an approval test? Check out a brief [overview here](http://staxmanade.co
|
|
|
69
69
|
|
|
70
70
|
## Getting Started
|
|
71
71
|
|
|
72
|
+
Mocha, Jest, and Vitest are optional peer dependencies. Install the framework
|
|
73
|
+
your tests use alongside Approvals. Approvals silently skips integrations for
|
|
74
|
+
frameworks that are not installed.
|
|
75
|
+
|
|
72
76
|
### Jest Typescript Starter Project
|
|
73
77
|
|
|
74
78
|
If you want to jump start a new project, clone the [Jest Starter Project](https://github.com/approvals/ApprovalTests.TypeScript.Jest.StarterProject)
|
|
@@ -90,10 +94,10 @@ Below is a simple getting started using Mocha.
|
|
|
90
94
|
npm install --save-dev @approval-tests/approvals
|
|
91
95
|
```
|
|
92
96
|
|
|
93
|
-
1. Install [Mocha](http://mochajs.org/)
|
|
97
|
+
1. Install [Mocha](http://mochajs.org/) in the project to execute our tests
|
|
94
98
|
|
|
95
99
|
```shell
|
|
96
|
-
npm install -
|
|
100
|
+
npm install --save-dev mocha
|
|
97
101
|
```
|
|
98
102
|
|
|
99
103
|
1. Create a sample Mocha test file called `SimpleLogger.test.js`.
|
|
@@ -112,7 +116,7 @@ Below is a simple getting started using Mocha.
|
|
|
112
116
|
1. Test the file with mocha.
|
|
113
117
|
|
|
114
118
|
```shell
|
|
115
|
-
mocha SimpleLogger.test.js
|
|
119
|
+
npx mocha SimpleLogger.test.js
|
|
116
120
|
```
|
|
117
121
|
|
|
118
122
|
1. You should be presented with a diff tool. (if not, you may need to install one?)
|
|
@@ -507,7 +511,7 @@ approvals.verifyAndScrub(__dirname, 'sample-approval-test', { a: "some text in a
|
|
|
507
511
|
### approvals~verifyWithControl(namer, writer, [reporterFactory], [optionsOverride])
|
|
508
512
|
This allows you to take full control of naming and writing files before verifying.
|
|
509
513
|
|
|
510
|
-
For an example that we use to generate the docs within the readme, check out the [test/readmeTests.mts](test/readmeTests.mts) in this project.
|
|
514
|
+
For an example that we use to generate the docs within the readme, check out the [test/mocha/readmeTests.mts](test/mocha/readmeTests.mts) in this project.
|
|
511
515
|
|
|
512
516
|
**Kind**: inner method of [<code>approvals</code>](#module_approvals)
|
|
513
517
|
|