borp 0.8.0 → 0.9.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/borp.js CHANGED
@@ -90,9 +90,7 @@ try {
90
90
 
91
91
  const reporters = {
92
92
  ...Reporters,
93
- gh: githubReporter,
94
- /* eslint new-cap: "off" */
95
- spec: new Reporters.spec()
93
+ gh: githubReporter
96
94
  }
97
95
 
98
96
  // If we're running in a GitHub action, adds the gh reporter
@@ -103,10 +101,8 @@ try {
103
101
 
104
102
  for (const input of args.values.reporter) {
105
103
  const [name, dest] = input.split(':')
106
- const reporter = reporters[name]
107
- if (!reporter) {
108
- throw new Error(`Unknown reporter: ${name}`)
109
- }
104
+ const Ctor = reporters[name] || await import(name).then((m) => m.default || m)
105
+ const reporter = Ctor.prototype && Object.getOwnPropertyDescriptor(Ctor.prototype, 'constructor') ? new Ctor() : Ctor
110
106
  let output = process.stdout
111
107
  if (dest) {
112
108
  output = createWriteStream(dest)
@@ -144,6 +140,7 @@ try {
144
140
  /* c8 ignore next 3 */
145
141
  } catch (err) {
146
142
  console.error(err)
143
+ process.exitCode = 1
147
144
  } finally {
148
145
  if (covDir) {
149
146
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "borp",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "node:test wrapper with TypeScript support",
6
6
  "main": "borp.js",
@@ -22,6 +22,7 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@matteo.collina/tspl": "^0.1.0",
25
+ "@reporters/silent": "^1.2.4",
25
26
  "@types/node": "^20.10.0",
26
27
  "desm": "^1.3.0",
27
28
  "snazzy": "^9.0.0",
package/test/cli.test.js CHANGED
@@ -60,3 +60,31 @@ test('disable ts and run no tests', async () => {
60
60
 
61
61
  strictEqual(stdout.indexOf('tests 0') >= 0, true)
62
62
  })
63
+
64
+ test('reporter from node_modules', async () => {
65
+ const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm')
66
+ const { stdout } = await execa('node', [
67
+ borp,
68
+ '--reporter=spec',
69
+ '--reporter=@reporters/silent'
70
+ ], {
71
+ cwd
72
+ })
73
+
74
+ strictEqual(stdout.indexOf('tests 2') >= 0, true)
75
+ })
76
+
77
+ test('gh reporter', async () => {
78
+ const cwd = join(import.meta.url, '..', 'fixtures', 'js-esm')
79
+ const { stdout } = await execa('node', [
80
+ borp,
81
+ '--reporter=gh'
82
+ ], {
83
+ cwd,
84
+ env: {
85
+ GITHUB_ACTIONS: '1'
86
+ }
87
+ })
88
+
89
+ strictEqual(stdout.indexOf('::notice') >= 0, true)
90
+ })