tape-six 1.1.1 → 1.2.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 -0
- package/bin/tape6-bun.js +20 -20
- package/bin/tape6-deno.js +20 -20
- package/bin/tape6-node.js +20 -20
- package/bin/tape6-runner.js +4 -3
- package/bin/tape6.js +3 -3
- package/index.js +2 -0
- package/package.json +4 -4
- package/src/JSONLReporter.js +10 -1
- package/src/TTYReporter.js +49 -3
- package/src/utils/config.js +33 -0
package/README.md
CHANGED
|
@@ -236,6 +236,8 @@ See [set-up tests](https://github.com/uhop/tape-six/wiki/Set-up-tests) for detai
|
|
|
236
236
|
|
|
237
237
|
The most recent releases:
|
|
238
238
|
|
|
239
|
+
- 1.2.0 _Updated dependencies + added an optional prefix for JSON lines._
|
|
240
|
+
- 1.1.2 _Updated dependencies._
|
|
239
241
|
- 1.1.1 _Technical re-release with the missing `index.d.ts` file._
|
|
240
242
|
- 1.1.0 _Added TypeScript support._
|
|
241
243
|
- 1.0.4 _Bugfix for platform-specific tests, old platforms, minor updates to accommodate Deno 2, updated dev deps._
|
package/bin/tape6-bun.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
resolveTests,
|
|
7
|
+
resolvePatterns,
|
|
8
|
+
getReporter as getReporterType
|
|
9
|
+
} from '../src/utils/config.js';
|
|
6
10
|
|
|
7
11
|
import {getReporter, setReporter} from '../src/test.js';
|
|
8
12
|
import State, {StopTest} from '../src/State.js';
|
|
9
|
-
import TapReporter from '../src/TapReporter.js';
|
|
10
13
|
import {selectTimer} from '../src/utils/timer.js';
|
|
11
14
|
|
|
12
15
|
import TestWorker from '../src/bun/TestWorker.js';
|
|
@@ -88,25 +91,22 @@ const config = () => {
|
|
|
88
91
|
if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
|
|
89
92
|
};
|
|
90
93
|
|
|
94
|
+
const reporters = {
|
|
95
|
+
jsonl: 'JSONLReporter.js',
|
|
96
|
+
tap: 'TapReporter.js',
|
|
97
|
+
tty: 'TTYReporter.js'
|
|
98
|
+
};
|
|
99
|
+
|
|
91
100
|
const init = async () => {
|
|
92
|
-
|
|
93
|
-
if (!
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ttyReporter.testCounter = -2;
|
|
102
|
-
ttyReporter.technicalDepth = 1;
|
|
103
|
-
reporter = ttyReporter.report.bind(ttyReporter);
|
|
104
|
-
}
|
|
105
|
-
if (!reporter) {
|
|
106
|
-
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
107
|
-
reporter = tapReporter.report.bind(tapReporter);
|
|
108
|
-
}
|
|
109
|
-
setReporter(reporter);
|
|
101
|
+
const currentReporter = getReporter();
|
|
102
|
+
if (!currentReporter) {
|
|
103
|
+
const reporterType = getReporterType(),
|
|
104
|
+
reporterFile = reporters[reporterType] || reporters.tty,
|
|
105
|
+
CustomReporter = (await import('../src/' + reporterFile)).default,
|
|
106
|
+
customOptions =
|
|
107
|
+
reporterType === 'tap' ? {useJson: true, hasColors: !options.monochrome} : options,
|
|
108
|
+
customReporter = new CustomReporter(customOptions);
|
|
109
|
+
setReporter(customReporter.report.bind(customReporter));
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (files.length) {
|
package/bin/tape6-deno.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
resolveTests,
|
|
7
|
+
resolvePatterns,
|
|
8
|
+
getReporter as getReporterType
|
|
9
|
+
} from '../src/utils/config.js';
|
|
6
10
|
|
|
7
11
|
import {getReporter, setReporter} from '../src/test.js';
|
|
8
12
|
import State, {StopTest} from '../src/State.js';
|
|
9
|
-
import TapReporter from '../src/TapReporter.js';
|
|
10
13
|
import {selectTimer} from '../src/utils/timer.js';
|
|
11
14
|
|
|
12
15
|
import TestWorker from '../src/deno/TestWorker.js';
|
|
@@ -88,25 +91,22 @@ const config = () => {
|
|
|
88
91
|
if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
|
|
89
92
|
};
|
|
90
93
|
|
|
94
|
+
const reporters = {
|
|
95
|
+
jsonl: 'JSONLReporter.js',
|
|
96
|
+
tap: 'TapReporter.js',
|
|
97
|
+
tty: 'TTYReporter.js'
|
|
98
|
+
};
|
|
99
|
+
|
|
91
100
|
const init = async () => {
|
|
92
|
-
|
|
93
|
-
if (!
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ttyReporter.testCounter = -2;
|
|
102
|
-
ttyReporter.technicalDepth = 1;
|
|
103
|
-
reporter = ttyReporter.report.bind(ttyReporter);
|
|
104
|
-
}
|
|
105
|
-
if (!reporter) {
|
|
106
|
-
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
107
|
-
reporter = tapReporter.report.bind(tapReporter);
|
|
108
|
-
}
|
|
109
|
-
setReporter(reporter);
|
|
101
|
+
const currentReporter = getReporter();
|
|
102
|
+
if (!currentReporter) {
|
|
103
|
+
const reporterType = getReporterType(),
|
|
104
|
+
reporterFile = reporters[reporterType] || reporters.tty,
|
|
105
|
+
CustomReporter = (await import('../src/' + reporterFile)).default,
|
|
106
|
+
customOptions =
|
|
107
|
+
reporterType === 'tap' ? {useJson: true, hasColors: !options.monochrome} : options,
|
|
108
|
+
customReporter = new CustomReporter(customOptions);
|
|
109
|
+
setReporter(customReporter.report.bind(customReporter));
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (files.length) {
|
package/bin/tape6-node.js
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import {fileURLToPath} from 'node:url';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
resolveTests,
|
|
8
|
+
resolvePatterns,
|
|
9
|
+
getReporter as getReporterType
|
|
10
|
+
} from '../src/utils/config.js';
|
|
7
11
|
|
|
8
12
|
import {getReporter, setReporter} from '../src/test.js';
|
|
9
13
|
import State, {StopTest} from '../src/State.js';
|
|
10
|
-
import TapReporter from '../src/TapReporter.js';
|
|
11
14
|
import {selectTimer} from '../src/utils/timer.js';
|
|
12
15
|
|
|
13
16
|
import TestWorker from '../src/node/TestWorker.js';
|
|
@@ -89,25 +92,22 @@ const config = () => {
|
|
|
89
92
|
if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
|
|
90
93
|
};
|
|
91
94
|
|
|
95
|
+
const reporters = {
|
|
96
|
+
jsonl: 'JSONLReporter.js',
|
|
97
|
+
tap: 'TapReporter.js',
|
|
98
|
+
tty: 'TTYReporter.js'
|
|
99
|
+
};
|
|
100
|
+
|
|
92
101
|
const init = async () => {
|
|
93
|
-
|
|
94
|
-
if (!
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
ttyReporter.testCounter = -2;
|
|
103
|
-
ttyReporter.technicalDepth = 1;
|
|
104
|
-
reporter = ttyReporter.report.bind(ttyReporter);
|
|
105
|
-
}
|
|
106
|
-
if (!reporter) {
|
|
107
|
-
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
108
|
-
reporter = tapReporter.report.bind(tapReporter);
|
|
109
|
-
}
|
|
110
|
-
setReporter(reporter);
|
|
102
|
+
const currentReporter = getReporter();
|
|
103
|
+
if (!currentReporter) {
|
|
104
|
+
const reporterType = getReporterType(),
|
|
105
|
+
reporterFile = reporters[reporterType] || reporters.tty,
|
|
106
|
+
CustomReporter = (await import('../src/' + reporterFile)).default,
|
|
107
|
+
customOptions =
|
|
108
|
+
reporterType === 'tap' ? {useJson: true, hasColors: !options.monochrome} : options,
|
|
109
|
+
customReporter = new CustomReporter(customOptions);
|
|
110
|
+
setReporter(customReporter.report.bind(customReporter));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
if (files.length) {
|
package/bin/tape6-runner.js
CHANGED
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import {fileURLToPath} from 'node:url';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const runtimeFiles = {
|
|
7
7
|
node: 'tape6-node.js',
|
|
8
8
|
deno: 'tape6-deno.js',
|
|
9
9
|
bun: 'tape6-bun.js',
|
|
10
10
|
server: 'tape6-server.js',
|
|
11
11
|
runner: 'tape6-runner.js',
|
|
12
12
|
main: 'tape6.js'
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
const requestedRuntime = runtimeFiles[process.argv[2]] || runtimeFiles.main;
|
|
14
15
|
|
|
15
|
-
const runtime = requestedRuntime
|
|
16
|
+
const runtime = requestedRuntime,
|
|
16
17
|
url = new URL('./' + runtime, import.meta.url),
|
|
17
18
|
fileName = url.protocol === 'file:' ? fileURLToPath(url) : url.href;
|
|
18
19
|
|
package/bin/tape6.js
CHANGED
|
@@ -11,11 +11,11 @@ if (process.argv.includes('--self')) {
|
|
|
11
11
|
console.log(self);
|
|
12
12
|
}
|
|
13
13
|
} else {
|
|
14
|
-
if (typeof Deno == 'object') {
|
|
14
|
+
if (typeof Deno == 'object' && Deno?.version) {
|
|
15
15
|
await import('./tape6-deno.js');
|
|
16
|
-
} else if (typeof Bun == 'object') {
|
|
16
|
+
} else if (typeof Bun == 'object' && Bun?.version) {
|
|
17
17
|
await import('./tape6-bun.js');
|
|
18
|
-
} else if (typeof process == 'object' && process
|
|
18
|
+
} else if (typeof process == 'object' && process?.versions?.node) {
|
|
19
19
|
await import('./tape6-node.js');
|
|
20
20
|
} else {
|
|
21
21
|
throw new Error('tape6 is not supported in this environment');
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tape-six",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "TAP the test harness for the modern JavaScript (ES6).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@types/node": "^
|
|
75
|
-
"puppeteer": "^24.
|
|
76
|
-
"typescript": "^5.
|
|
74
|
+
"@types/node": "^25.0.5",
|
|
75
|
+
"puppeteer": "^24.34.0",
|
|
76
|
+
"typescript": "^5.9.3"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/JSONLReporter.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
+
import {getEnv} from './utils/config.js';
|
|
2
|
+
|
|
1
3
|
class JSONLReporter {
|
|
2
4
|
constructor({renumberAsserts = false} = {}) {
|
|
3
5
|
this.renumberAsserts = renumberAsserts;
|
|
4
6
|
this.assertCounter = 0;
|
|
7
|
+
|
|
8
|
+
const env = getEnv({});
|
|
9
|
+
this.prefix = env.TAPE6_JSONL_PREFIX || '';
|
|
5
10
|
}
|
|
6
11
|
report(event) {
|
|
7
12
|
if (event.type === 'assert' && this.renumberAsserts) {
|
|
8
13
|
event = {...event, id: ++this.assertCounter};
|
|
9
14
|
}
|
|
10
|
-
|
|
15
|
+
if (this.prefix) {
|
|
16
|
+
console.log('\n' + this.prefix + JSON.stringify(event));
|
|
17
|
+
} else {
|
|
18
|
+
console.log(JSON.stringify(event));
|
|
19
|
+
}
|
|
11
20
|
}
|
|
12
21
|
}
|
|
13
22
|
|
package/src/TTYReporter.js
CHANGED
|
@@ -76,7 +76,40 @@ class TTYReporter {
|
|
|
76
76
|
this.failure = this.paint(failureStyle, reset);
|
|
77
77
|
this.skipped = this.paint(skippedStyle, reset);
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
// watching for console output
|
|
80
|
+
|
|
81
|
+
this.consoleWasUsed = false;
|
|
82
|
+
this.consoleLastNewLine = false;
|
|
83
|
+
this.consoleSkipChecks = false;
|
|
84
|
+
|
|
85
|
+
while (this.output.isTTY) {
|
|
86
|
+
this.out('');
|
|
87
|
+
|
|
88
|
+
const isCurrentTTY = this.output === process.stdout || this.output === process.stderr;
|
|
89
|
+
if (!isCurrentTTY) break;
|
|
90
|
+
|
|
91
|
+
const oldStdoutWrite = process.stdout.write;
|
|
92
|
+
process.stdout.write = process.stderr.write = (chunk, ...args) => {
|
|
93
|
+
if (!this.consoleSkipChecks && chunk) {
|
|
94
|
+
this.consoleWasUsed = true;
|
|
95
|
+
const text = chunk.toString();
|
|
96
|
+
this.consoleLastNewLine = text[text.length - 1] === '\n';
|
|
97
|
+
}
|
|
98
|
+
return oldStdoutWrite.call(process.stdout, chunk, ...args);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const oldStderrWrite = process.stderr.write;
|
|
102
|
+
process.stderr.write = (chunk, ...args) => {
|
|
103
|
+
if (!this.consoleSkipChecks && chunk) {
|
|
104
|
+
this.consoleWasUsed = true;
|
|
105
|
+
const text = chunk.toString();
|
|
106
|
+
this.consoleLastNewLine = text[text.length - 1] === '\n';
|
|
107
|
+
}
|
|
108
|
+
return oldStderrWrite.call(process.stderr, chunk, ...args);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
80
113
|
}
|
|
81
114
|
paint(prefix, suffix = '\x1B[39m') {
|
|
82
115
|
return this.hasColors ? text => join(prefix, text, suffix) : text => text;
|
|
@@ -100,9 +133,22 @@ class TTYReporter {
|
|
|
100
133
|
return this;
|
|
101
134
|
}
|
|
102
135
|
report(event) {
|
|
136
|
+
this.consoleSkipChecks = true;
|
|
137
|
+
try {
|
|
138
|
+
this.reportInternal(event);
|
|
139
|
+
} finally {
|
|
140
|
+
this.consoleSkipChecks = false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
reportInternal(event) {
|
|
103
144
|
if (this.output.isTTY) {
|
|
104
|
-
this.
|
|
105
|
-
|
|
145
|
+
if (this.consoleWasUsed) {
|
|
146
|
+
if (!this.consoleLastNewLine) this.output.write('\n');
|
|
147
|
+
this.consoleWasUsed = this.consoleLastNewLine = false;
|
|
148
|
+
} else {
|
|
149
|
+
this.output.moveCursor(0, -1);
|
|
150
|
+
this.output.clearLine(0);
|
|
151
|
+
}
|
|
106
152
|
}
|
|
107
153
|
let text;
|
|
108
154
|
switch (event.type) {
|
package/src/utils/config.js
CHANGED
|
@@ -64,3 +64,36 @@ export const resolveTests = async (rootFolder, type, traceFn) => {
|
|
|
64
64
|
// resolve patterns
|
|
65
65
|
return resolvePatterns(rootFolder, patterns);
|
|
66
66
|
};
|
|
67
|
+
|
|
68
|
+
export const runtime = {name: 'unknown', env: null};
|
|
69
|
+
|
|
70
|
+
if (typeof Deno == 'object' && Deno?.version) {
|
|
71
|
+
runtime.name = 'deno';
|
|
72
|
+
runtime.env = Deno.env;
|
|
73
|
+
} else if (typeof Bun == 'object' && Bun?.version) {
|
|
74
|
+
runtime.name = 'bun';
|
|
75
|
+
runtime.env = Bun.env;
|
|
76
|
+
} else if (typeof process == 'object' && process?.versions?.node) {
|
|
77
|
+
runtime.name = 'node';
|
|
78
|
+
runtime.env = process.env;
|
|
79
|
+
} else if (typeof window == 'object' && window?.document) {
|
|
80
|
+
runtime.name = 'browser';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const getEnv = (defaultEnv = null) => runtime.env || defaultEnv;
|
|
84
|
+
|
|
85
|
+
export const getReporter = () => {
|
|
86
|
+
const env = getEnv();
|
|
87
|
+
if (!env) return null;
|
|
88
|
+
if (env.TAPE6_REPORTER) return env.TAPE6_REPORTER;
|
|
89
|
+
if (env.TAPE6_JSONL) return 'jsonl';
|
|
90
|
+
if (env.TAPE6_TAP) return 'tap';
|
|
91
|
+
return 'tty';
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const getRunner = () => {
|
|
95
|
+
const env = getEnv();
|
|
96
|
+
if (!env) return null;
|
|
97
|
+
if (env.TAPE6_RUNNER) return env.TAPE6_RUNNER;
|
|
98
|
+
return 'thread';
|
|
99
|
+
};
|