@hedia/test 1.1.1 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/reporter.js +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedia/test",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
package/src/reporter.js CHANGED
@@ -1,14 +1,13 @@
1
- import { writeFileSync } from "fs";
1
+ import { readFileSync } from "fs";
2
+
2
3
  export default async function* testReporter(source) {
3
4
  try {
4
- const events = [];
5
+ let title = ''
5
6
  const tests = [];
6
7
  let nestedTitles = [];
7
8
  let nestingLevel = -1;
8
9
 
9
10
  for await (const event of source) {
10
- events.push(event);
11
-
12
11
  switch (event.type) {
13
12
  case "test:start":
14
13
  if (nestingLevel < event.data.nesting) {
@@ -56,10 +55,13 @@ export default async function* testReporter(source) {
56
55
  });
57
56
 
58
57
  break;
58
+ case "test:coverage":
59
+ const location = event.data.summary.workingDirectory + "/package.json"
60
+ const { name, version } = JSON.parse(readFileSync(location, 'utf8'))
61
+ title = `${name}@${version}`
59
62
  }
60
63
  }
61
64
 
62
- // const input = "http://localhost:8469/api/v1/reports";
63
65
  const input = "https://test.hedia.dev/api/v1/reports";
64
66
  const init = {
65
67
  method: "POST",
@@ -68,7 +70,7 @@ export default async function* testReporter(source) {
68
70
  },
69
71
  body: JSON.stringify(
70
72
  {
71
- title: new Date().toISOString(),
73
+ title,
72
74
  tests,
73
75
  },
74
76
  null,
@@ -80,8 +82,6 @@ export default async function* testReporter(source) {
80
82
 
81
83
  console.log(response.ok ? "OK" : "NOT OK");
82
84
  yield true;
83
-
84
- writeFileSync("./test-report.json", JSON.stringify(events, null, 4), "utf-8");
85
85
  } catch (err) {
86
86
  console.error(err.message);
87
87
  }