beartest-js 7.0.0 → 7.0.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.
- package/cli.js +7 -2
- package/index.d.ts +7 -7
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { run } = require('./beartest')
|
|
3
3
|
const fs = require('node:fs')
|
|
4
|
+
const path = require('node:path')
|
|
4
5
|
|
|
5
6
|
async function cli() {
|
|
6
7
|
const globStr = process.argv[2] || '**/*.test.*'
|
|
7
8
|
|
|
8
9
|
const files = await Array.fromAsync(fs.promises.glob(globStr))
|
|
9
10
|
|
|
10
|
-
for await (let event of run({ files: files })) {
|
|
11
|
+
for await (let event of run({ files: files.map((f) => path.resolve(f)) })) {
|
|
11
12
|
const prefix = ' '.repeat(event.data.nesting)
|
|
12
13
|
if (event.type === 'test:start' && event.data.type === 'suite') {
|
|
13
|
-
|
|
14
|
+
if (path.isAbsolute(event.data.name)) {
|
|
15
|
+
console.log(`\x1b[36m${prefix}${path.parse(event.data.name).name} (${path.relative('./', event.data.name)})\x1b[0m`)
|
|
16
|
+
} else {
|
|
17
|
+
console.log(`\x1b[36m${prefix}${event.data.name}\x1b[0m`)
|
|
18
|
+
}
|
|
14
19
|
} else if (event.type === 'test:pass' && event.data.details.type === 'test' && !event.data.skip) {
|
|
15
20
|
process.stdout.write(`\x1b[32m${prefix}✓\x1b[0m\x1b[90m ${event.data.name}\n\x1b[0m`)
|
|
16
21
|
} else if (event.type === 'test:fail' && event.data.details.type === 'test') {
|
package/index.d.ts
CHANGED
|
@@ -72,14 +72,14 @@ export interface TestFail {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface TestFunction {
|
|
75
|
-
(name: string, fn: () =>
|
|
76
|
-
only(name: string, fn: () =>
|
|
77
|
-
skip(name: string, fn: () =>
|
|
75
|
+
(name: string, fn: () => unknown): void
|
|
76
|
+
only(name: string, fn: () => unknown): void
|
|
77
|
+
skip(name: string, fn: () => unknown): void
|
|
78
78
|
describe: DescribeFunction
|
|
79
|
-
before(callback: () =>
|
|
80
|
-
beforeEach(callback: () =>
|
|
81
|
-
after(callback: () =>
|
|
82
|
-
afterEach(callback: () =>
|
|
79
|
+
before(callback: () => unknown): void
|
|
80
|
+
beforeEach(callback: () => unknown): void
|
|
81
|
+
after(callback: () => unknown): void
|
|
82
|
+
afterEach(callback: () => unknown): void
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export interface DescribeFunction {
|