@optique/testing 1.3.0-dev.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/LICENSE +20 -0
- package/README.md +42 -0
- package/dist/cli.cjs +0 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +0 -0
- package/dist/discover.cjs +0 -0
- package/dist/discover.d.cts +1 -0
- package/dist/discover.d.ts +1 -0
- package/dist/discover.js +0 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +0 -0
- package/dist/parser.cjs +0 -0
- package/dist/parser.d.cts +1 -0
- package/dist/parser.d.ts +1 -0
- package/dist/parser.js +0 -0
- package/dist/run.cjs +0 -0
- package/dist/run.d.cts +1 -0
- package/dist/run.d.ts +1 -0
- package/dist/run.js +0 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2025–2026 Hong Minhee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@optique/testing
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
Testing support for [Optique] command-line interfaces.
|
|
5
|
+
|
|
6
|
+
An Optique application can be exercised at four distinct execution boundaries,
|
|
7
|
+
and this package gives each one its own entry point, so the scope of a test is
|
|
8
|
+
visible from its import:
|
|
9
|
+
|
|
10
|
+
- *@optique/testing/parser*: a parser on its own, without help rendering,
|
|
11
|
+
process integration, or command dispatch.
|
|
12
|
+
- *@optique/testing/run*: what `run()` and `runAsync()` write through their
|
|
13
|
+
injected output callbacks, plus intentional exits.
|
|
14
|
+
- *@optique/testing/discover*: a `runProgram()` invocation, including command
|
|
15
|
+
discovery and handler dispatch.
|
|
16
|
+
- *@optique/testing/cli*: a real CLI entry point in a child process.
|
|
17
|
+
|
|
18
|
+
The package root holds only the contracts that mean the same thing at more than
|
|
19
|
+
one boundary. It depends on no test framework and no assertion library.
|
|
20
|
+
|
|
21
|
+
[Optique]: https://optique.dev/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Installation
|
|
25
|
+
------------
|
|
26
|
+
|
|
27
|
+
~~~~ bash
|
|
28
|
+
deno add jsr:@optique/testing
|
|
29
|
+
npm add @optique/testing
|
|
30
|
+
pnpm add @optique/testing
|
|
31
|
+
yarn add @optique/testing
|
|
32
|
+
bun add @optique/testing
|
|
33
|
+
~~~~
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Documentation
|
|
37
|
+
-------------
|
|
38
|
+
|
|
39
|
+
For full documentation, visit the [testing guide], which explains what each
|
|
40
|
+
layer does and does not execute, and how to choose between them.
|
|
41
|
+
|
|
42
|
+
[testing guide]: https://optique.dev/concepts/testing
|
package/dist/cli.cjs
ADDED
|
File without changes
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.js
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/discover.js
ADDED
|
File without changes
|
package/dist/index.cjs
ADDED
|
File without changes
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Testing support for Optique command-line interfaces.
|
|
4
|
+
*
|
|
5
|
+
* An Optique application can be exercised at four distinct execution
|
|
6
|
+
* boundaries, and this package gives each one its own entry point:
|
|
7
|
+
*
|
|
8
|
+
* - `@optique/testing/parser` runs a parser against an argument list without
|
|
9
|
+
* help rendering, process integration, or command dispatch.
|
|
10
|
+
* - `@optique/testing/run` captures what `run()` and `runAsync()` write
|
|
11
|
+
* through their injected output callbacks, along with intentional exits.
|
|
12
|
+
* - `@optique/testing/discover` captures a `runProgram()` invocation,
|
|
13
|
+
* including command discovery and handler dispatch.
|
|
14
|
+
* - `@optique/testing/cli` invokes a real CLI entry point in a child process.
|
|
15
|
+
*
|
|
16
|
+
* This module holds only the contracts that mean the same thing at more than
|
|
17
|
+
* one of those boundaries. Results that differ by layer—parsed values,
|
|
18
|
+
* intentional exits, terminating signals—belong to the subpath that produces
|
|
19
|
+
* them.
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
* @since 1.3.0
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Text captured from a program's standard output and standard error streams.
|
|
26
|
+
*
|
|
27
|
+
* The two streams are kept apart and their text is preserved exactly, so a
|
|
28
|
+
* test can assert on trailing newlines and on which stream a message reached.
|
|
29
|
+
* Each layer documents how it fills these fields: the in-process layers
|
|
30
|
+
* accumulate the text their injected writers receive, while the subprocess
|
|
31
|
+
* layer decodes whatever the child actually wrote.
|
|
32
|
+
*
|
|
33
|
+
* @since 1.3.0
|
|
34
|
+
*/
|
|
35
|
+
interface CapturedOutput {
|
|
36
|
+
/**
|
|
37
|
+
* The text written to standard output. Empty when nothing was written.
|
|
38
|
+
*/
|
|
39
|
+
readonly stdout: string;
|
|
40
|
+
/**
|
|
41
|
+
* The text written to standard error. Empty when nothing was written.
|
|
42
|
+
*/
|
|
43
|
+
readonly stderr: string;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { CapturedOutput };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Testing support for Optique command-line interfaces.
|
|
4
|
+
*
|
|
5
|
+
* An Optique application can be exercised at four distinct execution
|
|
6
|
+
* boundaries, and this package gives each one its own entry point:
|
|
7
|
+
*
|
|
8
|
+
* - `@optique/testing/parser` runs a parser against an argument list without
|
|
9
|
+
* help rendering, process integration, or command dispatch.
|
|
10
|
+
* - `@optique/testing/run` captures what `run()` and `runAsync()` write
|
|
11
|
+
* through their injected output callbacks, along with intentional exits.
|
|
12
|
+
* - `@optique/testing/discover` captures a `runProgram()` invocation,
|
|
13
|
+
* including command discovery and handler dispatch.
|
|
14
|
+
* - `@optique/testing/cli` invokes a real CLI entry point in a child process.
|
|
15
|
+
*
|
|
16
|
+
* This module holds only the contracts that mean the same thing at more than
|
|
17
|
+
* one of those boundaries. Results that differ by layer—parsed values,
|
|
18
|
+
* intentional exits, terminating signals—belong to the subpath that produces
|
|
19
|
+
* them.
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
* @since 1.3.0
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Text captured from a program's standard output and standard error streams.
|
|
26
|
+
*
|
|
27
|
+
* The two streams are kept apart and their text is preserved exactly, so a
|
|
28
|
+
* test can assert on trailing newlines and on which stream a message reached.
|
|
29
|
+
* Each layer documents how it fills these fields: the in-process layers
|
|
30
|
+
* accumulate the text their injected writers receive, while the subprocess
|
|
31
|
+
* layer decodes whatever the child actually wrote.
|
|
32
|
+
*
|
|
33
|
+
* @since 1.3.0
|
|
34
|
+
*/
|
|
35
|
+
interface CapturedOutput {
|
|
36
|
+
/**
|
|
37
|
+
* The text written to standard output. Empty when nothing was written.
|
|
38
|
+
*/
|
|
39
|
+
readonly stdout: string;
|
|
40
|
+
/**
|
|
41
|
+
* The text written to standard error. Empty when nothing was written.
|
|
42
|
+
*/
|
|
43
|
+
readonly stderr: string;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { CapturedOutput };
|
package/dist/index.js
ADDED
|
File without changes
|
package/dist/parser.cjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/parser.js
ADDED
|
File without changes
|
package/dist/run.cjs
ADDED
|
File without changes
|
package/dist/run.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/run.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@optique/testing",
|
|
3
|
+
"version": "1.3.0-dev.0",
|
|
4
|
+
"description": "Testing support for Optique command-line interfaces",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"CLI",
|
|
7
|
+
"command-line",
|
|
8
|
+
"commandline",
|
|
9
|
+
"parser",
|
|
10
|
+
"testing",
|
|
11
|
+
"subprocess"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Hong Minhee",
|
|
16
|
+
"email": "hong@minhee.org",
|
|
17
|
+
"url": "https://hongminhee.org/"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://optique.dev/",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/dahlia/optique.git",
|
|
23
|
+
"directory": "packages/testing/"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/dahlia/optique/issues"
|
|
27
|
+
},
|
|
28
|
+
"funding": [
|
|
29
|
+
"https://github.com/sponsors/dahlia"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.0.0",
|
|
33
|
+
"bun": ">=1.2.0",
|
|
34
|
+
"deno": ">=2.3.0"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/",
|
|
38
|
+
"package.json",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"type": "module",
|
|
42
|
+
"module": "./dist/index.js",
|
|
43
|
+
"main": "./dist/index.cjs",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": {
|
|
48
|
+
"import": "./dist/index.d.ts",
|
|
49
|
+
"require": "./dist/index.d.cts"
|
|
50
|
+
},
|
|
51
|
+
"import": "./dist/index.js",
|
|
52
|
+
"require": "./dist/index.cjs"
|
|
53
|
+
},
|
|
54
|
+
"./cli": {
|
|
55
|
+
"types": {
|
|
56
|
+
"import": "./dist/cli.d.ts",
|
|
57
|
+
"require": "./dist/cli.d.cts"
|
|
58
|
+
},
|
|
59
|
+
"import": "./dist/cli.js",
|
|
60
|
+
"require": "./dist/cli.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./discover": {
|
|
63
|
+
"types": {
|
|
64
|
+
"import": "./dist/discover.d.ts",
|
|
65
|
+
"require": "./dist/discover.d.cts"
|
|
66
|
+
},
|
|
67
|
+
"import": "./dist/discover.js",
|
|
68
|
+
"require": "./dist/discover.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./parser": {
|
|
71
|
+
"types": {
|
|
72
|
+
"import": "./dist/parser.d.ts",
|
|
73
|
+
"require": "./dist/parser.d.cts"
|
|
74
|
+
},
|
|
75
|
+
"import": "./dist/parser.js",
|
|
76
|
+
"require": "./dist/parser.cjs"
|
|
77
|
+
},
|
|
78
|
+
"./run": {
|
|
79
|
+
"types": {
|
|
80
|
+
"import": "./dist/run.d.ts",
|
|
81
|
+
"require": "./dist/run.d.cts"
|
|
82
|
+
},
|
|
83
|
+
"import": "./dist/run.js",
|
|
84
|
+
"require": "./dist/run.cjs"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"sideEffects": false,
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@types/node": "^24.0.0",
|
|
90
|
+
"tsdown": "^0.13.0",
|
|
91
|
+
"typescript": "^5.8.3"
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsdown",
|
|
95
|
+
"prepublish": "tsdown",
|
|
96
|
+
"test": "node --test",
|
|
97
|
+
"test:bun": "bun test",
|
|
98
|
+
"test:deno": "deno test --allow-read",
|
|
99
|
+
"test-all": "tsdown && node --test && bun test && deno test --allow-read"
|
|
100
|
+
}
|
|
101
|
+
}
|