@jsenv/snapshot 2.14.0 → 2.14.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/snapshot",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@jsenv/exception": "1.1.7",
|
|
37
37
|
"@jsenv/humanize": "1.4.0",
|
|
38
38
|
"@jsenv/filesystem": "4.14.6",
|
|
39
|
-
"@jsenv/terminal-recorder": "1.5.
|
|
39
|
+
"@jsenv/terminal-recorder": "1.5.10",
|
|
40
40
|
"@jsenv/urls": "2.7.1",
|
|
41
41
|
"@jsenv/utils": "2.3.0",
|
|
42
42
|
"ansi-regex": "6.1.0",
|
package/src/main.js
CHANGED
|
@@ -5,6 +5,7 @@ export {
|
|
|
5
5
|
export { createReplaceFilesystemWellKnownValues } from "./filesystem_well_known_values.js";
|
|
6
6
|
export { getCallerLocation } from "./get_caller_location.js";
|
|
7
7
|
export { replaceFluctuatingValues } from "./replace_fluctuating_values.js";
|
|
8
|
+
export { captureLogsIntoFile } from "./side_effects/capture_logs_into_file.js";
|
|
8
9
|
export { renderLogsGif } from "./side_effects/render_logs_gif.js";
|
|
9
10
|
export { snapshotSideEffects } from "./side_effects/snapshot_side_effects.js";
|
|
10
11
|
export { snapshotTests } from "./side_effects/snapshot_tests.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCaptureSideEffects } from "./create_capture_side_effects.js";
|
|
2
|
+
import { renderLogsSvg } from "./render_logs_svg.js";
|
|
3
|
+
|
|
4
|
+
export const captureLogsIntoFile = async (fn, { svgFileUrl }) => {
|
|
5
|
+
const capture = createCaptureSideEffects({
|
|
6
|
+
executionEffects: false,
|
|
7
|
+
filesystemEffects: false,
|
|
8
|
+
logEffects: {
|
|
9
|
+
group: false,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const sideEffects = await capture(fn);
|
|
13
|
+
renderLogsSvg(sideEffects, svgFileUrl);
|
|
14
|
+
};
|
|
@@ -71,7 +71,7 @@ export const logSideEffects = (logSideEffectsOptions) => {
|
|
|
71
71
|
const logGroupSideEffect = {
|
|
72
72
|
code: "log_group",
|
|
73
73
|
type: `log_group`,
|
|
74
|
-
value: {},
|
|
74
|
+
value: {}, // TODO: the concatenation of the logs
|
|
75
75
|
render: {
|
|
76
76
|
md: (options) => {
|
|
77
77
|
const renderLogGroup = () => {
|
|
@@ -2,7 +2,7 @@ import { writeFileSync } from "@jsenv/filesystem";
|
|
|
2
2
|
import { startTerminalRecording } from "@jsenv/terminal-recorder";
|
|
3
3
|
import { isLogSideEffect } from "./log/log_side_effects.js";
|
|
4
4
|
|
|
5
|
-
export const renderLogsGif = async (sideEffects,
|
|
5
|
+
export const renderLogsGif = async (sideEffects, gifFileUrl) => {
|
|
6
6
|
const terminalRecorder = await startTerminalRecording({
|
|
7
7
|
gif: true,
|
|
8
8
|
});
|
|
@@ -15,5 +15,5 @@ export const renderLogsGif = async (sideEffects, gitFileUrl) => {
|
|
|
15
15
|
}
|
|
16
16
|
const result = await terminalRecorder.stop();
|
|
17
17
|
const gif = await result.gif();
|
|
18
|
-
writeFileSync(new URL(
|
|
18
|
+
writeFileSync(new URL(gifFileUrl), gif);
|
|
19
19
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { writeFileSync } from "@jsenv/filesystem";
|
|
2
|
+
import { startTerminalRecording } from "@jsenv/terminal-recorder";
|
|
3
|
+
import { isLogSideEffect } from "./log/log_side_effects.js";
|
|
4
|
+
|
|
5
|
+
export const renderLogsSvg = async (
|
|
6
|
+
sideEffects,
|
|
7
|
+
svgFileUrl,
|
|
8
|
+
svgOptions = {},
|
|
9
|
+
) => {
|
|
10
|
+
const terminalRecorder = await startTerminalRecording({
|
|
11
|
+
svg: {
|
|
12
|
+
title: "Terminal",
|
|
13
|
+
width: "auto",
|
|
14
|
+
...svgOptions,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
for (const sideEffect of sideEffects) {
|
|
18
|
+
if (isLogSideEffect(sideEffect)) {
|
|
19
|
+
await terminalRecorder.write(`${sideEffect.value}\n`, {
|
|
20
|
+
delay: sideEffect.delay,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const result = await terminalRecorder.stop();
|
|
25
|
+
const svg = await result.svg();
|
|
26
|
+
writeFileSync(new URL(svgFileUrl), svg);
|
|
27
|
+
};
|