sxy-test-runner 2.4.2 → 2.4.3

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.
@@ -21,6 +21,16 @@ function alignMessage(message, spacer) {
21
21
  ? [line]
22
22
  : (line.trim()) ? [...previous, spacer + line] : previous, []).join('\n');
23
23
  }
24
+ // A multi line string is shown as text, indented under its label. inspect() would render it
25
+ // as one quoted chunk per line joined with `+`, which buries the content it is there to
26
+ // show. Everything else - objects, and single line strings, whose quotes reveal padding and
27
+ // emptiness - still goes through inspect.
28
+ function showValue(value, column) {
29
+ if (typeof value !== 'string' || !value.includes('\n')) {
30
+ return inspect(value, { depth: 5 });
31
+ }
32
+ return value.split('\n').join(`\n${column}`);
33
+ }
24
34
  export async function showTestResult(config, testResult, customOut) {
25
35
  const out = customOut ?? mainOut;
26
36
  await timeProfileAsync('show test result', () => {
@@ -92,8 +102,9 @@ export async function showTestResult(config, testResult, customOut) {
92
102
  out(chalk.mediumred(`${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`));
93
103
  // shown whenever the error carries them, so a falsy actual or
94
104
  // expected - 0, '', false, null - still gets its diff
95
- out(_chalk.yellow `${spacer}Actual ${inspect(err.actual, { depth: 5 })}\n`
96
- + _chalk.blueBright `${spacer}Expected ${inspect(err.expected, { depth: 5 })}`);
105
+ const valueColumn = `${spacer} `;
106
+ out(_chalk.yellow `${spacer}Actual ${showValue(err.actual, valueColumn)}\n`
107
+ + _chalk.blueBright `${spacer}Expected ${showValue(err.expected, valueColumn)}`);
97
108
  }
98
109
  else {
99
110
  out(chalk.mediumred(`${spacer}${err.name}: ${alignMessage(err.message, spacer)}`));
@@ -1 +1 @@
1
- {"version":3,"file":"showTestResult.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,C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G,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAC/D,CAAC,CAAA;wBACN,CAAC;wBACD,cAAc;wBACd,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;4BACxB,GAAG,EAAE,CAAA;4BACL,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;wBACpC,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,GAAG,EAAE,CAAA;gBACL,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA,eAAe,CAAC,CAAA;oBAC9B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACxB,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;oBACF,GAAG,EAAE,CAAA;gBACT,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport _chalk from 'chalk'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { indexNumberToLetters } from '../../indexNumberToLetters.js'\n\nimport type { FinalConfig, OutFn, TestError, TestResult } from '../../types.js'\nimport { inspect } from 'node:util'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// Assertion failures are recognised by shape, not by where they came from. Importing an\n// assertion library to test `instanceof` against cannot work here: the runner would need it\n// as a dependency, and the copy a test file throws from is a separate ESM instance anyway,\n// so the check fails for the very errors it is meant to catch.\nfunction isAssertionLike(error: TestError): boolean {\n return 'actual' in error || 'expected' in error\n}\n\n// Node's assertion messages run to several lines. Later lines are indented to the message\n// column and blank ones dropped; a single line message passes through untouched.\nfunction alignMessage(message: string, spacer: string): string {\n return message.split('\\n').reduce<string[]>(\n (previous, line) => (previous.length === 0)\n ? [line]\n : (line.trim()) ? [...previous, spacer + line] : previous,\n []\n ).join('\\n')\n}\n\nexport async function showTestResult(config: FinalConfig, testResult: TestResult, customOut?: OutFn): Promise<void> {\n const out = customOut ?? mainOut\n\n await timeProfileAsync('show test result', () => {\n out()\n out(chalk.grey`File ${testResult.file}`)\n\n const indent = ' '\n\n if (testResult.logs.length > 0) {\n out()\n out(chalk.grey`console.logs:`)\n testResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n let first = true\n\n for (const describeResult of testResult.describeResults) {\n if (!first) out()\n first = false\n\n out(chalk.lightgrey`${describeResult.counter}) describing ` + chalk.brightblue(describeResult.thing)\n + chalk.grey` ${describeResult.time.toLocaleString()}ms`)\n out()\n\n if (describeResult.logs && describeResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n describeResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n if (describeResult.error !== undefined) {\n const describeError = describeResult.error\n const describeErrorText = (\n typeof describeError === 'object'\n && describeError !== null\n && 'name' in describeError\n && 'message' in describeError\n && typeof describeError.name === 'string'\n && typeof describeError.message === 'string'\n )\n ? `${describeError.name}: ${describeError.message}`\n : String(describeError) // eslint-disable-line @typescript-eslint/no-base-to-string -- only a fallback, if it gives poor results, change it\n\n out(chalk.mediumred(`${indent}Threw:`))\n out(chalk.mediumred(`${indent}${describeErrorText}`))\n if (config.showErrorTrace) {\n const describeErrorStack = (\n typeof describeError === 'object'\n && describeError !== null\n && 'stack' in describeError\n && typeof describeError.stack === 'string'\n )\n ? describeError.stack\n : ''\n out()\n out(chalk.grey(describeErrorStack))\n }\n out()\n }\n\n for (const itResult of describeResult.itResults) {\n const letters = indexNumberToLetters(itResult.counter) ?? ''\n const itTime = chalk.grey` ${itResult.time.toLocaleString()}ms`\n if (itResult.success === true) {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumgreen` ${figures.tick} ${itResult.should}` + itTime)\n } else {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumred` ${figures.cross} ${itResult.should}` + itTime)\n out()\n const spacer = `${indent}${' '.repeat(letters.length)} `\n const err = itResult.error\n if (err) {\n if (isAssertionLike(err)) {\n out(chalk.mediumred(\n `${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`\n ))\n // shown whenever the error carries them, so a falsy actual or\n // expected - 0, '', false, null - still gets its diff\n out(\n _chalk.yellow`${spacer}Actual ${inspect(err.actual, { depth: 5 })}\\n`\n + _chalk.blueBright`${spacer}Expected ${inspect(err.expected, { depth: 5 })}`\n )\n } else {\n out(chalk.mediumred(\n `${spacer}${err.name}: ${alignMessage(err.message, spacer)}`\n ))\n }\n // stack trace\n if (config.showErrorTrace) {\n out()\n out(chalk.grey(err.stack ?? ''))\n }\n }\n }\n\n out()\n if (itResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n itResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n }\n }\n })\n}\n"]}
1
+ {"version":3,"file":"showTestResult.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,MAAM,MAAM,OAAO,CAAA;AAC1B,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,wFAAwF;AACxF,4FA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GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAC/D,CAAC,CAAA;wBACN,CAAC;wBACD,cAAc;wBACd,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;4BACxB,GAAG,EAAE,CAAA;4BACL,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;wBACpC,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,GAAG,EAAE,CAAA;gBACL,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA,eAAe,CAAC,CAAA;oBAC9B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACxB,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;oBACF,GAAG,EAAE,CAAA;gBACT,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport _chalk from 'chalk'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { indexNumberToLetters } from '../../indexNumberToLetters.js'\n\nimport type { FinalConfig, OutFn, TestError, TestResult } from '../../types.js'\nimport { inspect } from 'node:util'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// Assertion failures are recognised by shape, not by where they came from. Importing an\n// assertion library to test `instanceof` against cannot work here: the runner would need it\n// as a dependency, and the copy a test file throws from is a separate ESM instance anyway,\n// so the check fails for the very errors it is meant to catch.\nfunction isAssertionLike(error: TestError): boolean {\n return 'actual' in error || 'expected' in error\n}\n\n// Node's assertion messages run to several lines. Later lines are indented to the message\n// column and blank ones dropped; a single line message passes through untouched.\nfunction alignMessage(message: string, spacer: string): string {\n return message.split('\\n').reduce<string[]>(\n (previous, line) => (previous.length === 0)\n ? [line]\n : (line.trim()) ? [...previous, spacer + line] : previous,\n []\n ).join('\\n')\n}\n\n// A multi line string is shown as text, indented under its label. inspect() would render it\n// as one quoted chunk per line joined with `+`, which buries the content it is there to\n// show. Everything else - objects, and single line strings, whose quotes reveal padding and\n// emptiness - still goes through inspect.\nfunction showValue(value: unknown, column: string): string {\n if (typeof value !== 'string' || !value.includes('\\n')) {\n return inspect(value, { depth: 5 })\n }\n return value.split('\\n').join(`\\n${column}`)\n}\n\nexport async function showTestResult(config: FinalConfig, testResult: TestResult, customOut?: OutFn): Promise<void> {\n const out = customOut ?? mainOut\n\n await timeProfileAsync('show test result', () => {\n out()\n out(chalk.grey`File ${testResult.file}`)\n\n const indent = ' '\n\n if (testResult.logs.length > 0) {\n out()\n out(chalk.grey`console.logs:`)\n testResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n let first = true\n\n for (const describeResult of testResult.describeResults) {\n if (!first) out()\n first = false\n\n out(chalk.lightgrey`${describeResult.counter}) describing ` + chalk.brightblue(describeResult.thing)\n + chalk.grey` ${describeResult.time.toLocaleString()}ms`)\n out()\n\n if (describeResult.logs && describeResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n describeResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n if (describeResult.error !== undefined) {\n const describeError = describeResult.error\n const describeErrorText = (\n typeof describeError === 'object'\n && describeError !== null\n && 'name' in describeError\n && 'message' in describeError\n && typeof describeError.name === 'string'\n && typeof describeError.message === 'string'\n )\n ? `${describeError.name}: ${describeError.message}`\n : String(describeError) // eslint-disable-line @typescript-eslint/no-base-to-string -- only a fallback, if it gives poor results, change it\n\n out(chalk.mediumred(`${indent}Threw:`))\n out(chalk.mediumred(`${indent}${describeErrorText}`))\n if (config.showErrorTrace) {\n const describeErrorStack = (\n typeof describeError === 'object'\n && describeError !== null\n && 'stack' in describeError\n && typeof describeError.stack === 'string'\n )\n ? describeError.stack\n : ''\n out()\n out(chalk.grey(describeErrorStack))\n }\n out()\n }\n\n for (const itResult of describeResult.itResults) {\n const letters = indexNumberToLetters(itResult.counter) ?? ''\n const itTime = chalk.grey` ${itResult.time.toLocaleString()}ms`\n if (itResult.success === true) {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumgreen` ${figures.tick} ${itResult.should}` + itTime)\n } else {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumred` ${figures.cross} ${itResult.should}` + itTime)\n out()\n const spacer = `${indent}${' '.repeat(letters.length)} `\n const err = itResult.error\n if (err) {\n if (isAssertionLike(err)) {\n out(chalk.mediumred(\n `${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`\n ))\n // shown whenever the error carries them, so a falsy actual or\n // expected - 0, '', false, null - still gets its diff\n const valueColumn = `${spacer} `\n out(\n _chalk.yellow`${spacer}Actual ${showValue(err.actual, valueColumn)}\\n`\n + _chalk.blueBright`${spacer}Expected ${showValue(err.expected, valueColumn)}`\n )\n } else {\n out(chalk.mediumred(\n `${spacer}${err.name}: ${alignMessage(err.message, spacer)}`\n ))\n }\n // stack trace\n if (config.showErrorTrace) {\n out()\n out(chalk.grey(err.stack ?? ''))\n }\n }\n }\n\n out()\n if (itResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n itResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n }\n }\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sxy-test-runner",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/RobertSandiford/sxy-test-runner",
6
6
  "repository": {