proby 0.2.0 → 0.2.2

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 (2) hide show
  1. package/lib/run.js +26 -3
  2. package/package.json +3 -3
package/lib/run.js CHANGED
@@ -4,6 +4,29 @@ import red from "@rcompat/cli/color/red";
4
4
  import print from "@rcompat/cli/print";
5
5
  import repository from "@rcompat/test/repository";
6
6
  const endings = [".spec.ts", ".spec.js"];
7
+ const primitives = ["bigint", "boolean", "string", "number", "symbol"];
8
+ function stringify(value) {
9
+ if (value === null)
10
+ return "null";
11
+ if (value === undefined)
12
+ return "undefined";
13
+ if (primitives.includes(typeof value)) {
14
+ return value.toString();
15
+ }
16
+ if (typeof value === "function") {
17
+ return `[Function${value.name ? `: ${value.name}` : ""}]`;
18
+ }
19
+ if (typeof value === "object") {
20
+ try {
21
+ return JSON.stringify(value);
22
+ }
23
+ catch {
24
+ return "[Object (circular or unserializable)]";
25
+ }
26
+ }
27
+ // Fallback
28
+ return String(value);
29
+ }
7
30
  export default async (root, subrepo) => {
8
31
  const files = await root.list(file => endings.some(ending => file.path.endsWith(ending)), { recursive: true });
9
32
  if (files.length === 0) {
@@ -17,7 +40,7 @@ export default async (root, subrepo) => {
17
40
  print(`${blue(subrepo)}\n`);
18
41
  }
19
42
  const failed = [];
20
- for (const test of repository.run()) {
43
+ for await (const test of repository.run()) {
21
44
  for (const result of test.results) {
22
45
  if (result.passed) {
23
46
  print(green("o"));
@@ -33,8 +56,8 @@ export default async (root, subrepo) => {
33
56
  print("\n");
34
57
  for (const [test, result] of failed) {
35
58
  print(`${test.file.debase(root)} ${red(test.name)} \n`);
36
- print(` expected ${result.expected}\n`);
37
- print(` actual ${result.actual}\n`);
59
+ print(` expected ${stringify(result.expected)}\n`);
60
+ print(` actual ${stringify(result.actual)}\n`);
38
61
  }
39
62
  }
40
63
  print("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proby",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Standard library test runner",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",
@@ -17,11 +17,11 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@rcompat/cli": "^0.9.0",
20
- "@rcompat/fs": "^0.13.0",
20
+ "@rcompat/fs": "^0.13.2",
21
21
  "@rcompat/package": "^0.12.0"
22
22
  },
23
23
  "peerDependencies": {
24
- "@rcompat/test": "^0.2.0"
24
+ "@rcompat/test": "^0.2.1"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "@rcompat/test": {