@jsenv/test 3.3.8 → 3.3.10

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.
@@ -4845,6 +4845,7 @@ const reporterList = ({
4845
4845
  const log = renderExecutionLog(
4846
4846
  execution,
4847
4847
  logOptions,
4848
+ testPlanResult,
4848
4849
  testPlanHelpers,
4849
4850
  );
4850
4851
  if (log) {
@@ -4868,6 +4869,7 @@ const reporterList = ({
4868
4869
  const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
4869
4870
  let frameIndex = 0;
4870
4871
  let oneExecutionWritten = false;
4872
+ const memoryHeapUsedAtStart = memoryUsage().heapUsed;
4871
4873
  const renderDynamicLog = (testPlanResult) => {
4872
4874
  frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
4873
4875
  let dynamicLogContent = "";
@@ -4887,12 +4889,18 @@ const reporterList = ({
4887
4889
  rounded: false,
4888
4890
  });
4889
4891
  infos.push(ANSI.color(duration, ANSI.GREY));
4892
+ let memoryUsageColor = ANSI.GREY;
4890
4893
  const memoryHeapUsed = memoryUsage().heapUsed;
4894
+ if (memoryHeapUsed > 2.5 * memoryHeapUsedAtStart) {
4895
+ memoryUsageColor = ANSI.YELLOW;
4896
+ } else if (memoryHeapUsed > 1.5 * memoryHeapUsedAtStart) {
4897
+ memoryUsageColor = null;
4898
+ }
4891
4899
  const memoryHeapUsedFormatted = humanizeMemory(memoryHeapUsed, {
4892
4900
  short: true,
4893
4901
  decimals: 0,
4894
4902
  });
4895
- infos.push(ANSI.color(memoryHeapUsedFormatted, ANSI.GREY));
4903
+ infos.push(ANSI.color(memoryHeapUsedFormatted, memoryUsageColor));
4896
4904
 
4897
4905
  const infoFormatted = infos.join(ANSI.color(`/`, ANSI.GREY));
4898
4906
  dynamicLogContent += ` ${ANSI.color(
@@ -4924,6 +4932,7 @@ const reporterList = ({
4924
4932
  const log = renderExecutionLog(
4925
4933
  execution,
4926
4934
  logOptions,
4935
+ testPlanResult,
4927
4936
  testPlanHelpers,
4928
4937
  );
4929
4938
  if (log) {
@@ -5055,6 +5064,7 @@ const renderIntro = (testPlanResult, logOptions) => {
5055
5064
  const renderExecutionLog = (
5056
5065
  execution,
5057
5066
  logOptions,
5067
+ testPlanResult,
5058
5068
  { getPreviousExecution, getNextExecution },
5059
5069
  ) => {
5060
5070
  if (execution.skipped) {
@@ -5130,16 +5140,28 @@ const renderExecutionLabel = (execution, logOptions) => {
5130
5140
  const { timings, memoryUsage } = execution.result;
5131
5141
  if (timings) {
5132
5142
  const duration = timings.executionEnd - timings.executionStart;
5133
- const durationFormatted = logOptions.mockFluctuatingValues
5134
- ? `<mock>ms`
5135
- : humanizeDuration(duration, { short: true });
5136
- infos.push(ANSI.color(durationFormatted, ANSI.GREY));
5143
+ if (logOptions.mockFluctuatingValues) {
5144
+ infos.push(ANSI.color(`<mock>ms`, ANSI.GREY));
5145
+ } else {
5146
+ let color = ANSI.GREY;
5147
+ if (duration > 0.8 * execution.params.allocatedMs) {
5148
+ color = ANSI.YELLOW;
5149
+ } else if (duration > 0.3 * execution.params.allocatedMs) {
5150
+ color = null;
5151
+ }
5152
+ infos.push(
5153
+ ANSI.color(humanizeDuration(duration, { short: true }), color),
5154
+ );
5155
+ }
5137
5156
  }
5138
5157
  if (logOptions.memoryUsage && typeof memoryUsage === "number") {
5139
- const memoryUsageFormatted = logOptions.mockFluctuatingValues
5140
- ? `<mock>MB`
5141
- : humanizeMemory(memoryUsage, { short: true });
5142
- infos.push(ANSI.color(memoryUsageFormatted, ANSI.GREY));
5158
+ if (logOptions.mockFluctuatingValues) {
5159
+ infos.push(ANSI.color(`<mock>MB`, ANSI.GREY));
5160
+ } else {
5161
+ infos.push(
5162
+ ANSI.color(humanizeMemory(memoryUsage, { short: true }), ANSI.GREY),
5163
+ );
5164
+ }
5143
5165
  }
5144
5166
  if (infos.length) {
5145
5167
  const runtimeInfo = infos.join(ANSI.color(`/`, ANSI.GREY));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.3.8",
3
+ "version": "3.3.10",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "@jsenv/filesystem": "4.8.0",
43
43
  "@jsenv/github-check-run": "0.1.21",
44
44
  "@jsenv/humanize": "1.2.4",
45
- "@jsenv/plugin-supervisor": "1.5.2",
45
+ "@jsenv/plugin-supervisor": "1.5.3",
46
46
  "@jsenv/sourcemap": "1.2.14",
47
47
  "@jsenv/url-meta": "8.4.2",
48
48
  "@jsenv/urls": "2.2.11",
@@ -90,6 +90,7 @@ export const reporterList = ({
90
90
  const log = renderExecutionLog(
91
91
  execution,
92
92
  logOptions,
93
+ testPlanResult,
93
94
  testPlanHelpers,
94
95
  );
95
96
  if (log) {
@@ -113,6 +114,7 @@ export const reporterList = ({
113
114
  const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
114
115
  let frameIndex = 0;
115
116
  let oneExecutionWritten = false;
117
+ const memoryHeapUsedAtStart = processMemoryUsage().heapUsed;
116
118
  const renderDynamicLog = (testPlanResult) => {
117
119
  frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
118
120
  let dynamicLogContent = "";
@@ -132,12 +134,18 @@ export const reporterList = ({
132
134
  rounded: false,
133
135
  });
134
136
  infos.push(ANSI.color(duration, ANSI.GREY));
137
+ let memoryUsageColor = ANSI.GREY;
135
138
  const memoryHeapUsed = processMemoryUsage().heapUsed;
139
+ if (memoryHeapUsed > 2.5 * memoryHeapUsedAtStart) {
140
+ memoryUsageColor = ANSI.YELLOW;
141
+ } else if (memoryHeapUsed > 1.5 * memoryHeapUsedAtStart) {
142
+ memoryUsageColor = null;
143
+ }
136
144
  const memoryHeapUsedFormatted = humanizeMemory(memoryHeapUsed, {
137
145
  short: true,
138
146
  decimals: 0,
139
147
  });
140
- infos.push(ANSI.color(memoryHeapUsedFormatted, ANSI.GREY));
148
+ infos.push(ANSI.color(memoryHeapUsedFormatted, memoryUsageColor));
141
149
 
142
150
  const infoFormatted = infos.join(ANSI.color(`/`, ANSI.GREY));
143
151
  dynamicLogContent += ` ${ANSI.color(
@@ -169,6 +177,7 @@ export const reporterList = ({
169
177
  const log = renderExecutionLog(
170
178
  execution,
171
179
  logOptions,
180
+ testPlanResult,
172
181
  testPlanHelpers,
173
182
  );
174
183
  if (log) {
@@ -300,6 +309,7 @@ const renderIntro = (testPlanResult, logOptions) => {
300
309
  const renderExecutionLog = (
301
310
  execution,
302
311
  logOptions,
312
+ testPlanResult,
303
313
  { getPreviousExecution, getNextExecution },
304
314
  ) => {
305
315
  if (execution.skipped) {
@@ -330,7 +340,7 @@ const renderExecutionLog = (
330
340
  let log = "";
331
341
  // label
332
342
  {
333
- const label = renderExecutionLabel(execution, logOptions);
343
+ const label = renderExecutionLabel(execution, logOptions, testPlanResult);
334
344
  log += label;
335
345
  }
336
346
  // console calls
@@ -375,16 +385,28 @@ const renderExecutionLabel = (execution, logOptions) => {
375
385
  const { timings, memoryUsage } = execution.result;
376
386
  if (timings) {
377
387
  const duration = timings.executionEnd - timings.executionStart;
378
- const durationFormatted = logOptions.mockFluctuatingValues
379
- ? `<mock>ms`
380
- : humanizeDuration(duration, { short: true });
381
- infos.push(ANSI.color(durationFormatted, ANSI.GREY));
388
+ if (logOptions.mockFluctuatingValues) {
389
+ infos.push(ANSI.color(`<mock>ms`, ANSI.GREY));
390
+ } else {
391
+ let color = ANSI.GREY;
392
+ if (duration > 0.8 * execution.params.allocatedMs) {
393
+ color = ANSI.YELLOW;
394
+ } else if (duration > 0.3 * execution.params.allocatedMs) {
395
+ color = null;
396
+ }
397
+ infos.push(
398
+ ANSI.color(humanizeDuration(duration, { short: true }), color),
399
+ );
400
+ }
382
401
  }
383
402
  if (logOptions.memoryUsage && typeof memoryUsage === "number") {
384
- const memoryUsageFormatted = logOptions.mockFluctuatingValues
385
- ? `<mock>MB`
386
- : humanizeMemory(memoryUsage, { short: true });
387
- infos.push(ANSI.color(memoryUsageFormatted, ANSI.GREY));
403
+ if (logOptions.mockFluctuatingValues) {
404
+ infos.push(ANSI.color(`<mock>MB`, ANSI.GREY));
405
+ } else {
406
+ infos.push(
407
+ ANSI.color(humanizeMemory(memoryUsage, { short: true }), ANSI.GREY),
408
+ );
409
+ }
388
410
  }
389
411
  if (infos.length) {
390
412
  const runtimeInfo = infos.join(ANSI.color(`/`, ANSI.GREY));