borp 0.6.0 → 0.7.0
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/README.md +2 -1
- package/borp.js +2 -0
- package/fixtures/ts-esm2/src/add.ts +4 -0
- package/fixtures/ts-esm2/test/add.test.ts +7 -0
- package/fixtures/ts-esm2/test/add2.test.ts +7 -0
- package/fixtures/ts-esm2/tsconfig.json +24 -0
- package/lib/run.js +6 -1
- package/package.json +1 -1
- package/test/basic.test.js +1 -1
- package/test/cli.test.js +17 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# borp
|
|
2
2
|
|
|
3
|
-
Borp is a typescript-aware runner for
|
|
3
|
+
Borp is a typescript-aware test runner for `node:test`.
|
|
4
4
|
It also support code coverage via [c8](http://npm.im/c8).
|
|
5
5
|
|
|
6
6
|
Borp is self-hosted, i.e. Borp runs its own tests.
|
|
@@ -94,6 +94,7 @@ Note the use of `incremental: true`, which speed up compilation massively.
|
|
|
94
94
|
* `--expose-gc`, exposes the gc() function to tests
|
|
95
95
|
* `--pattern` or `-p`, run tests matching the given glob pattern
|
|
96
96
|
* `--reporter` or `-r`, set up a reporter, use a colon to set a file destination. Default: `spec`.
|
|
97
|
+
* `--no-typescript` or `-T`, disable automatic TypeScript compilation if `tsconfig.json` is found.
|
|
97
98
|
|
|
98
99
|
## Reporters
|
|
99
100
|
|
package/borp.js
CHANGED
|
@@ -32,6 +32,7 @@ const args = parseArgs({
|
|
|
32
32
|
ignore: { type: 'string', short: 'i', multiple: true },
|
|
33
33
|
'expose-gc': { type: 'boolean' },
|
|
34
34
|
help: { type: 'boolean', short: 'h' },
|
|
35
|
+
'no-typescript': { type: 'boolean', short: 'T' },
|
|
35
36
|
reporter: {
|
|
36
37
|
type: 'string',
|
|
37
38
|
short: 'r',
|
|
@@ -78,6 +79,7 @@ if (args.values.coverage) {
|
|
|
78
79
|
|
|
79
80
|
const config = {
|
|
80
81
|
...args.values,
|
|
82
|
+
typescript: !args.values['no-typescript'],
|
|
81
83
|
files: args.positionals,
|
|
82
84
|
pattern: args.values.pattern,
|
|
83
85
|
cwd: process.cwd()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"sourceMap": true,
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"module": "NodeNext",
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"removeComments": true,
|
|
13
|
+
"newLine": "lf",
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"lib": [
|
|
20
|
+
"ESNext"
|
|
21
|
+
],
|
|
22
|
+
"incremental": true
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/run.js
CHANGED
|
@@ -28,7 +28,7 @@ export default async function runWithTypeScript (config) {
|
|
|
28
28
|
let prefix = ''
|
|
29
29
|
let tscPath
|
|
30
30
|
|
|
31
|
-
if (tsconfigPath) {
|
|
31
|
+
if (tsconfigPath && config.typescript !== false) {
|
|
32
32
|
const _require = createRequire(tsconfigPath)
|
|
33
33
|
const typescriptPathCWD = _require.resolve('typescript')
|
|
34
34
|
tscPath = join(typescriptPathCWD, '..', '..', 'bin', 'tsc')
|
|
@@ -56,6 +56,11 @@ export default async function runWithTypeScript (config) {
|
|
|
56
56
|
prefix = join(dirname(tsconfigPath), outDir)
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
// TODO remove those and create a new object
|
|
61
|
+
delete config.typescript
|
|
62
|
+
delete config['no-typescript']
|
|
63
|
+
|
|
59
64
|
config.prefix = prefix
|
|
60
65
|
config.setup = (test) => {
|
|
61
66
|
/* c8 ignore next 12 */
|
package/package.json
CHANGED
package/test/basic.test.js
CHANGED
|
@@ -46,7 +46,7 @@ test('ts-cjs', async (t) => {
|
|
|
46
46
|
await completed
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
-
test('ts-esm with named
|
|
49
|
+
test('ts-esm with named files', async (t) => {
|
|
50
50
|
const { strictEqual, completed, match } = tspl(t, { plan: 3 })
|
|
51
51
|
const config = {
|
|
52
52
|
files: ['test/add.test.ts'],
|
package/test/cli.test.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { test } from 'node:test'
|
|
2
2
|
import { execa } from 'execa'
|
|
3
3
|
import { join } from 'desm'
|
|
4
|
-
import { rejects } from 'node:assert'
|
|
4
|
+
import { rejects, strictEqual } from 'node:assert'
|
|
5
|
+
import { rm } from 'node:fs/promises'
|
|
6
|
+
import path from 'node:path'
|
|
5
7
|
|
|
6
8
|
const borp = join(import.meta.url, '..', 'borp.js')
|
|
7
9
|
|
|
@@ -44,3 +46,17 @@ test('failing test with --expose-gc flag sets correct status code', async () =>
|
|
|
44
46
|
cwd: join(import.meta.url, '..', 'fixtures', 'fails')
|
|
45
47
|
}))
|
|
46
48
|
})
|
|
49
|
+
|
|
50
|
+
test('disable ts and run no tests', async () => {
|
|
51
|
+
const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm2')
|
|
52
|
+
await rm(path.join(cwd, 'dist'), { recursive: true, force: true })
|
|
53
|
+
const { stdout } = await execa('node', [
|
|
54
|
+
borp,
|
|
55
|
+
'--reporter=spec',
|
|
56
|
+
'--no-typescript'
|
|
57
|
+
], {
|
|
58
|
+
cwd
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
strictEqual(stdout.indexOf('tests 0') >= 0, true)
|
|
62
|
+
})
|