@nexusgpu/repterm-plugin-kubectl 0.1.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 +277 -0
- package/dist/index.d.ts +314 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +544 -0
- package/dist/matchers.d.ts +113 -0
- package/dist/matchers.d.ts.map +1 -0
- package/dist/matchers.js +527 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.d.ts +10 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.js +51 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.d.ts +13 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.js +86 -0
- package/dist/plugin-kubectl/examples/02-debugging.d.ts +13 -0
- package/dist/plugin-kubectl/examples/02-debugging.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/02-debugging.js +80 -0
- package/dist/plugin-kubectl/examples/03-resource-management.d.ts +13 -0
- package/dist/plugin-kubectl/examples/03-resource-management.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/03-resource-management.js +134 -0
- package/dist/plugin-kubectl/examples/04-rollout.d.ts +13 -0
- package/dist/plugin-kubectl/examples/04-rollout.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/04-rollout.js +122 -0
- package/dist/plugin-kubectl/examples/05-matchers.d.ts +15 -0
- package/dist/plugin-kubectl/examples/05-matchers.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/05-matchers.js +138 -0
- package/dist/plugin-kubectl/examples/06-advanced.d.ts +14 -0
- package/dist/plugin-kubectl/examples/06-advanced.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/06-advanced.js +140 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.js +66 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.js +145 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.js +123 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.d.ts +17 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.js +96 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.js +117 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.js +145 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.js +235 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.d.ts +15 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.js +146 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.js +141 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.d.ts +15 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.js +256 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.d.ts +71 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.js +159 -0
- package/dist/plugin-kubectl/src/index.d.ts +314 -0
- package/dist/plugin-kubectl/src/index.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/index.js +545 -0
- package/dist/plugin-kubectl/src/matchers.d.ts +113 -0
- package/dist/plugin-kubectl/src/matchers.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/matchers.js +527 -0
- package/dist/plugin-kubectl/src/result.d.ts +80 -0
- package/dist/plugin-kubectl/src/result.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/result.js +134 -0
- package/dist/repterm/src/api/describe.d.ts +18 -0
- package/dist/repterm/src/api/describe.d.ts.map +1 -0
- package/dist/repterm/src/api/describe.js +32 -0
- package/dist/repterm/src/api/expect.d.ts +43 -0
- package/dist/repterm/src/api/expect.d.ts.map +1 -0
- package/dist/repterm/src/api/expect.js +166 -0
- package/dist/repterm/src/api/hooks.d.ts +178 -0
- package/dist/repterm/src/api/hooks.d.ts.map +1 -0
- package/dist/repterm/src/api/hooks.js +230 -0
- package/dist/repterm/src/api/steps.d.ts +45 -0
- package/dist/repterm/src/api/steps.d.ts.map +1 -0
- package/dist/repterm/src/api/steps.js +105 -0
- package/dist/repterm/src/api/test.d.ts +101 -0
- package/dist/repterm/src/api/test.d.ts.map +1 -0
- package/dist/repterm/src/api/test.js +206 -0
- package/dist/repterm/src/index.d.ts +15 -0
- package/dist/repterm/src/index.d.ts.map +1 -0
- package/dist/repterm/src/index.js +23 -0
- package/dist/repterm/src/plugin/index.d.ts +47 -0
- package/dist/repterm/src/plugin/index.d.ts.map +1 -0
- package/dist/repterm/src/plugin/index.js +85 -0
- package/dist/repterm/src/plugin/withPlugins.d.ts +71 -0
- package/dist/repterm/src/plugin/withPlugins.d.ts.map +1 -0
- package/dist/repterm/src/plugin/withPlugins.js +100 -0
- package/dist/repterm/src/runner/models.d.ts +261 -0
- package/dist/repterm/src/runner/models.d.ts.map +1 -0
- package/dist/repterm/src/runner/models.js +4 -0
- package/dist/result.d.ts +80 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +134 -0
- package/package.json +38 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repterm - CLI/TUI Test Framework
|
|
3
|
+
*
|
|
4
|
+
* Public API entrypoint following Modern, Declarative conventions
|
|
5
|
+
*/
|
|
6
|
+
export { test, getTests, clearTests, registry } from './api/test.js';
|
|
7
|
+
export { expect, AssertionError, type MatcherResult, } from './api/expect.js';
|
|
8
|
+
export { describe } from './api/describe.js';
|
|
9
|
+
export { step, getCurrentStepOptions, getCurrentStepName, shouldShowStepTitle, markStepTitleShown, type StepRecordingOptions } from './api/steps.js';
|
|
10
|
+
export { beforeEach, afterEach, beforeAll, afterAll } from './api/hooks.js';
|
|
11
|
+
export type { TestContext, TerminalAPI, WaitOptions, CommandResult, RunOptions, PTYProcess, NamedHookEntry, PluginFactory, TerminalWithPlugins } from './runner/models.js';
|
|
12
|
+
export type { TestFunction, TestOptions, DescribeOptions } from './runner/models.js';
|
|
13
|
+
export type { HookFunction, EnhancedHookFunction } from './api/hooks.js';
|
|
14
|
+
export { definePlugin, defineConfig, createTestWithPlugins, describeWithPlugins, type PluginDefinition, type AnyPlugin, type PluginConfig, type PluginHooks, type BasePluginContext, type AugmentedTestContext, type PluginTestFunction, } from './plugin/index.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../repterm/src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,MAAM,EACN,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,IAAI,EACJ,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG5E,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC3K,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrF,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repterm - CLI/TUI Test Framework
|
|
3
|
+
*
|
|
4
|
+
* Public API entrypoint following Modern, Declarative conventions
|
|
5
|
+
*/
|
|
6
|
+
// Core test registration and execution
|
|
7
|
+
export { test, getTests, clearTests, registry } from './api/test.js';
|
|
8
|
+
export { expect, AssertionError, } from './api/expect.js';
|
|
9
|
+
// Test organization features
|
|
10
|
+
export { describe } from './api/describe.js';
|
|
11
|
+
export { step, getCurrentStepOptions, getCurrentStepName, shouldShowStepTitle, markStepTitleShown } from './api/steps.js';
|
|
12
|
+
export { beforeEach, afterEach, beforeAll, afterAll } from './api/hooks.js';
|
|
13
|
+
// Plugin system
|
|
14
|
+
export { definePlugin, defineConfig, createTestWithPlugins, describeWithPlugins, } from './plugin/index.js';
|
|
15
|
+
// Attach step to test namespace for test.step() syntax
|
|
16
|
+
import { test as testFn } from './api/test.js';
|
|
17
|
+
import { step as stepFn } from './api/steps.js';
|
|
18
|
+
import { describe as describeFn } from './api/describe.js';
|
|
19
|
+
// Extend test with additional methods
|
|
20
|
+
Object.assign(testFn, {
|
|
21
|
+
step: stepFn,
|
|
22
|
+
describe: describeFn,
|
|
23
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repterm Plugin System
|
|
3
|
+
*
|
|
4
|
+
* A type-safe plugin system that allows extending test contexts and terminal APIs.
|
|
5
|
+
* Types and definePlugin come from @repterm/plugin-api; runtime lives here.
|
|
6
|
+
*/
|
|
7
|
+
import type { TestContext } from '../runner/models.js';
|
|
8
|
+
import { definePlugin as definePluginFromApi, type BasePluginContext as BasePluginContextGeneric, type PluginHooks, type PluginDefinition, type AnyPlugin } from '@repterm/plugin-api';
|
|
9
|
+
export { definePluginFromApi as definePlugin };
|
|
10
|
+
export type { PluginDefinition, AnyPlugin, PluginHooks };
|
|
11
|
+
export type BasePluginContext = BasePluginContextGeneric<TestContext>;
|
|
12
|
+
type ExtractContextOut<T> = T extends PluginDefinition<any, any, infer Out, any> ? Out : {};
|
|
13
|
+
type ExtractMethods<T> = T extends PluginDefinition<any, any, any, infer M> ? M : {};
|
|
14
|
+
type ExtractName<T> = T extends PluginDefinition<infer N, any, any, any> ? N : never;
|
|
15
|
+
type MergePluginMethods<TPlugins extends readonly AnyPlugin[]> = TPlugins extends readonly [
|
|
16
|
+
infer First,
|
|
17
|
+
...infer Rest
|
|
18
|
+
] ? Rest extends readonly AnyPlugin[] ? {
|
|
19
|
+
[K in ExtractName<First>]: ExtractMethods<First>;
|
|
20
|
+
} & MergePluginMethods<Rest> : {
|
|
21
|
+
[K in ExtractName<First>]: ExtractMethods<First>;
|
|
22
|
+
} : {};
|
|
23
|
+
type AccumulateContext<TPlugins extends readonly AnyPlugin[], TAccum extends object = {}> = TPlugins extends readonly [infer First, ...infer Rest] ? Rest extends readonly AnyPlugin[] ? AccumulateContext<Rest, TAccum & ExtractContextOut<First>> : TAccum & ExtractContextOut<First> : TAccum;
|
|
24
|
+
export type AugmentedTestContext<TPlugins extends readonly AnyPlugin[]> = TestContext & {
|
|
25
|
+
plugins: MergePluginMethods<TPlugins>;
|
|
26
|
+
} & AccumulateContext<TPlugins>;
|
|
27
|
+
export interface PluginConfig<TPlugins extends readonly AnyPlugin[]> {
|
|
28
|
+
plugins?: TPlugins;
|
|
29
|
+
baseContext?: Partial<Omit<BasePluginContextGeneric<TestContext>, 'testContext'>>;
|
|
30
|
+
}
|
|
31
|
+
export declare class PluginRuntime<TPlugins extends readonly AnyPlugin[]> {
|
|
32
|
+
private plugins;
|
|
33
|
+
private baseContext;
|
|
34
|
+
private pluginMethods;
|
|
35
|
+
private pluginHooks;
|
|
36
|
+
private contextAugmentations;
|
|
37
|
+
constructor(config: PluginConfig<TPlugins>);
|
|
38
|
+
initialize(testContext: TestContext): AugmentedTestContext<TPlugins>;
|
|
39
|
+
runBeforeTestHooks(ctx: TestContext): Promise<void>;
|
|
40
|
+
runAfterTestHooks(ctx: TestContext, error?: Error): Promise<void>;
|
|
41
|
+
runBeforeCommandHooks(command: string): Promise<string>;
|
|
42
|
+
runAfterOutputHooks(output: string): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
export declare function defineConfig<TPlugins extends readonly AnyPlugin[]>(config: PluginConfig<TPlugins>): PluginRuntime<TPlugins>;
|
|
45
|
+
export { BasePluginContext as PluginContext };
|
|
46
|
+
export { createTestWithPlugins, describeWithPlugins, type PluginTestFunction, } from './withPlugins.js';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../repterm/src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,KAAK,iBAAiB,IAAI,wBAAwB,EAClD,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAItE,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AAC5F,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACrF,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAErF,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;IAChF,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,oBAAoB,CAA+B;gBAE/C,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC;IAS1C,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC;IAgC9D,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUvD,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAS3D;AAED,wBAAgB,YAAY,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EAChE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC7B,aAAa,CAAC,QAAQ,CAAC,CAEzB;AAED,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,CAAC;AAE9C,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repterm Plugin System
|
|
3
|
+
*
|
|
4
|
+
* A type-safe plugin system that allows extending test contexts and terminal APIs.
|
|
5
|
+
* Types and definePlugin come from @repterm/plugin-api; runtime lives here.
|
|
6
|
+
*/
|
|
7
|
+
import { definePlugin as definePluginFromApi, } from '@repterm/plugin-api';
|
|
8
|
+
// Re-export plugin-api for consumers (repterm re-exports these from index)
|
|
9
|
+
export { definePluginFromApi as definePlugin };
|
|
10
|
+
// ============== Runtime Implementation ==============
|
|
11
|
+
export class PluginRuntime {
|
|
12
|
+
plugins;
|
|
13
|
+
baseContext;
|
|
14
|
+
pluginMethods = {};
|
|
15
|
+
pluginHooks = [];
|
|
16
|
+
contextAugmentations = {};
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.plugins = (config.plugins || []);
|
|
19
|
+
this.baseContext = {
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
debug: false,
|
|
22
|
+
...config.baseContext,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
initialize(testContext) {
|
|
26
|
+
const fullContext = {
|
|
27
|
+
...this.baseContext,
|
|
28
|
+
testContext,
|
|
29
|
+
};
|
|
30
|
+
let ctx = { ...fullContext };
|
|
31
|
+
for (const plugin of this.plugins) {
|
|
32
|
+
const result = plugin.setup(ctx);
|
|
33
|
+
this.pluginMethods[plugin.name] = result.methods;
|
|
34
|
+
if (result.hooks) {
|
|
35
|
+
this.pluginHooks.push(result.hooks);
|
|
36
|
+
}
|
|
37
|
+
if (result.context) {
|
|
38
|
+
ctx = { ...ctx, ...result.context };
|
|
39
|
+
Object.assign(this.contextAugmentations, result.context);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const augmentedContext = {
|
|
43
|
+
...testContext,
|
|
44
|
+
plugins: this.pluginMethods,
|
|
45
|
+
...this.contextAugmentations,
|
|
46
|
+
};
|
|
47
|
+
return augmentedContext;
|
|
48
|
+
}
|
|
49
|
+
async runBeforeTestHooks(ctx) {
|
|
50
|
+
for (const hooks of this.pluginHooks) {
|
|
51
|
+
if (hooks.beforeTest) {
|
|
52
|
+
await hooks.beforeTest(ctx);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async runAfterTestHooks(ctx, error) {
|
|
57
|
+
for (const hooks of this.pluginHooks) {
|
|
58
|
+
if (hooks.afterTest) {
|
|
59
|
+
await hooks.afterTest(ctx, error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async runBeforeCommandHooks(command) {
|
|
64
|
+
let result = command;
|
|
65
|
+
for (const hooks of this.pluginHooks) {
|
|
66
|
+
if (hooks.beforeCommand) {
|
|
67
|
+
result = await hooks.beforeCommand(result);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
async runAfterOutputHooks(output) {
|
|
73
|
+
let result = output;
|
|
74
|
+
for (const hooks of this.pluginHooks) {
|
|
75
|
+
if (hooks.afterOutput) {
|
|
76
|
+
result = await hooks.afterOutput(result);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function defineConfig(config) {
|
|
83
|
+
return new PluginRuntime(config);
|
|
84
|
+
}
|
|
85
|
+
export { createTestWithPlugins, describeWithPlugins, } from './withPlugins.js';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Integration Helpers
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to seamlessly integrate plugins with the test framework,
|
|
5
|
+
* eliminating the need for manual initialization in every test case.
|
|
6
|
+
*/
|
|
7
|
+
import { describe as describeFromDescribe } from '../api/describe.js';
|
|
8
|
+
import type { PluginRuntime, AnyPlugin, AugmentedTestContext } from './index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Type for the augmented test function that receives plugin context
|
|
11
|
+
*/
|
|
12
|
+
export type PluginTestFunction<TPlugins extends readonly AnyPlugin[]> = (ctx: AugmentedTestContext<TPlugins>) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a test function that automatically initializes plugins
|
|
15
|
+
*
|
|
16
|
+
* @param config - The plugin runtime configuration
|
|
17
|
+
* @returns A wrapped test function with automatic plugin initialization
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { defineConfig } from 'repterm';
|
|
22
|
+
* import { createTestWithPlugins } from 'repterm/plugin/withPlugins';
|
|
23
|
+
* import { loggerPlugin } from './plugins/logger';
|
|
24
|
+
*
|
|
25
|
+
* const config = defineConfig({
|
|
26
|
+
* plugins: [loggerPlugin()] as const,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* const test = createTestWithPlugins(config);
|
|
30
|
+
*
|
|
31
|
+
* test('my test', async (ctx) => {
|
|
32
|
+
* // ctx automatically includes all plugins!
|
|
33
|
+
* ctx.logger.info('Hello!');
|
|
34
|
+
* ctx.plugins.logger.log('info', 'World!');
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createTestWithPlugins<TPlugins extends readonly AnyPlugin[]>(config: PluginRuntime<TPlugins>): (name: string, fn: PluginTestFunction<TPlugins>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a describe block where all tests automatically have plugin access
|
|
41
|
+
*
|
|
42
|
+
* @param config - The plugin runtime configuration
|
|
43
|
+
* @param name - The describe block name
|
|
44
|
+
* @param fn - The describe block callback
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { defineConfig } from 'repterm';
|
|
49
|
+
* import { describeWithPlugins } from 'repterm/plugin/withPlugins';
|
|
50
|
+
* import { loggerPlugin } from './plugins/logger';
|
|
51
|
+
*
|
|
52
|
+
* const config = defineConfig({
|
|
53
|
+
* plugins: [loggerPlugin()] as const,
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* describeWithPlugins(config, 'My Suite', ({ test }) => {
|
|
57
|
+
* test('test 1', async (ctx) => {
|
|
58
|
+
* ctx.logger.info('Auto-initialized!');
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* test('test 2', async (ctx) => {
|
|
62
|
+
* ctx.logger.debug('Same here!');
|
|
63
|
+
* });
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function describeWithPlugins<TPlugins extends readonly AnyPlugin[]>(config: PluginRuntime<TPlugins>, name: string, fn: (helpers: {
|
|
68
|
+
test: ReturnType<typeof createTestWithPlugins<TPlugins>>;
|
|
69
|
+
describe: typeof describeFromDescribe;
|
|
70
|
+
}) => void): void;
|
|
71
|
+
//# sourceMappingURL=withPlugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPlugins.d.ts","sourceRoot":"","sources":["../../../../../repterm/src/plugin/withPlugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEjF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,IAAI,CACpE,GAAG,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAClC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACvE,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,UAMrB,MAAM,MACR,kBAAkB,CAAC,QAAQ,CAAC,KACjC,IAAI,CAiCV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACrE,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,EAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,OAAO,EAAE;IACV,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzD,QAAQ,EAAE,OAAO,oBAAoB,CAAC;CACzC,KAAK,IAAI,GACX,IAAI,CAKN"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Integration Helpers
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to seamlessly integrate plugins with the test framework,
|
|
5
|
+
* eliminating the need for manual initialization in every test case.
|
|
6
|
+
*/
|
|
7
|
+
import { test as baseTest } from '../api/test.js';
|
|
8
|
+
import { describe as describeFromDescribe } from '../api/describe.js';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a test function that automatically initializes plugins
|
|
11
|
+
*
|
|
12
|
+
* @param config - The plugin runtime configuration
|
|
13
|
+
* @returns A wrapped test function with automatic plugin initialization
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { defineConfig } from 'repterm';
|
|
18
|
+
* import { createTestWithPlugins } from 'repterm/plugin/withPlugins';
|
|
19
|
+
* import { loggerPlugin } from './plugins/logger';
|
|
20
|
+
*
|
|
21
|
+
* const config = defineConfig({
|
|
22
|
+
* plugins: [loggerPlugin()] as const,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const test = createTestWithPlugins(config);
|
|
26
|
+
*
|
|
27
|
+
* test('my test', async (ctx) => {
|
|
28
|
+
* // ctx automatically includes all plugins!
|
|
29
|
+
* ctx.logger.info('Hello!');
|
|
30
|
+
* ctx.plugins.logger.log('info', 'World!');
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function createTestWithPlugins(config) {
|
|
35
|
+
/**
|
|
36
|
+
* Wrapped test function with automatic plugin initialization
|
|
37
|
+
*/
|
|
38
|
+
function testWithPlugins(name, fn) {
|
|
39
|
+
baseTest(name, async ({ terminal }) => {
|
|
40
|
+
// Create plugin factory for new terminals
|
|
41
|
+
const pluginFactory = (newTerminal) => {
|
|
42
|
+
// Initialize plugins with new terminal context
|
|
43
|
+
const newCtx = config.initialize({ terminal: newTerminal });
|
|
44
|
+
return newCtx.plugins;
|
|
45
|
+
};
|
|
46
|
+
// Inject plugin factory into terminal
|
|
47
|
+
terminal.setPluginFactory?.(pluginFactory);
|
|
48
|
+
// Initialize plugins with test context
|
|
49
|
+
const augmentedCtx = config.initialize({ terminal });
|
|
50
|
+
// Run beforeTest hooks
|
|
51
|
+
await config.runBeforeTestHooks({ terminal });
|
|
52
|
+
try {
|
|
53
|
+
// Execute the test with augmented context
|
|
54
|
+
await fn(augmentedCtx);
|
|
55
|
+
// Run afterTest hooks (success)
|
|
56
|
+
await config.runAfterTestHooks({ terminal });
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// Run afterTest hooks (failure)
|
|
60
|
+
await config.runAfterTestHooks({ terminal }, error);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return testWithPlugins;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a describe block where all tests automatically have plugin access
|
|
69
|
+
*
|
|
70
|
+
* @param config - The plugin runtime configuration
|
|
71
|
+
* @param name - The describe block name
|
|
72
|
+
* @param fn - The describe block callback
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { defineConfig } from 'repterm';
|
|
77
|
+
* import { describeWithPlugins } from 'repterm/plugin/withPlugins';
|
|
78
|
+
* import { loggerPlugin } from './plugins/logger';
|
|
79
|
+
*
|
|
80
|
+
* const config = defineConfig({
|
|
81
|
+
* plugins: [loggerPlugin()] as const,
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* describeWithPlugins(config, 'My Suite', ({ test }) => {
|
|
85
|
+
* test('test 1', async (ctx) => {
|
|
86
|
+
* ctx.logger.info('Auto-initialized!');
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* test('test 2', async (ctx) => {
|
|
90
|
+
* ctx.logger.debug('Same here!');
|
|
91
|
+
* });
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export function describeWithPlugins(config, name, fn) {
|
|
96
|
+
describeFromDescribe(name, () => {
|
|
97
|
+
const test = createTestWithPlugins(config);
|
|
98
|
+
fn({ test, describe: describeFromDescribe });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core entities for the test framework
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* test() 函数的配置选项
|
|
6
|
+
*/
|
|
7
|
+
export interface TestOptions {
|
|
8
|
+
/** 标记为录制测试,仅在 --record 模式下运行 */
|
|
9
|
+
record?: boolean;
|
|
10
|
+
/** 测试超时时间(毫秒) */
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* describe() 函数的配置选项
|
|
15
|
+
*/
|
|
16
|
+
export interface DescribeOptions {
|
|
17
|
+
/** 标记为录制测试套件,内部所有测试默认继承此配置 */
|
|
18
|
+
record?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Named hook entry for beforeAll/afterAll
|
|
22
|
+
*/
|
|
23
|
+
export interface NamedHookEntry {
|
|
24
|
+
name?: string;
|
|
25
|
+
fn: (context: TestContext) => Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
|
|
26
|
+
}
|
|
27
|
+
export interface TestSuite {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
tests: TestCase[];
|
|
31
|
+
suites?: TestSuite[];
|
|
32
|
+
parent?: TestSuite;
|
|
33
|
+
config: SuiteConfig;
|
|
34
|
+
options?: DescribeOptions;
|
|
35
|
+
beforeAll?: NamedHookEntry[];
|
|
36
|
+
afterAll?: NamedHookEntry[];
|
|
37
|
+
}
|
|
38
|
+
export interface SuiteConfig {
|
|
39
|
+
timeouts?: {
|
|
40
|
+
suiteMs?: number;
|
|
41
|
+
testMs?: number;
|
|
42
|
+
};
|
|
43
|
+
parallel?: {
|
|
44
|
+
workers?: number;
|
|
45
|
+
};
|
|
46
|
+
record?: {
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
castFile?: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface TestCase {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
steps: Step[];
|
|
55
|
+
timeout?: number;
|
|
56
|
+
fixtures?: Record<string, unknown>;
|
|
57
|
+
fn: TestFunction;
|
|
58
|
+
options?: TestOptions;
|
|
59
|
+
}
|
|
60
|
+
export type TestFunction = (context: TestContext) => Promise<void>;
|
|
61
|
+
export interface TestContext {
|
|
62
|
+
terminal: TerminalAPI;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 命令执行结果
|
|
67
|
+
*/
|
|
68
|
+
export interface CommandResult {
|
|
69
|
+
/** 命令退出码(0 表示成功) */
|
|
70
|
+
code: number;
|
|
71
|
+
/** 标准输出 */
|
|
72
|
+
stdout: string;
|
|
73
|
+
/** 标准错误 */
|
|
74
|
+
stderr: string;
|
|
75
|
+
/** 混合输出(stdout + stderr 合并) */
|
|
76
|
+
output: string;
|
|
77
|
+
/** 命令执行时长(毫秒) */
|
|
78
|
+
duration: number;
|
|
79
|
+
/** 原始命令字符串 */
|
|
80
|
+
command: string;
|
|
81
|
+
/** 是否成功(code === 0) */
|
|
82
|
+
readonly successful: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* PTY 进程控制器
|
|
86
|
+
* 实现 PromiseLike,既可以作为 Promise 使用(await 自动调用 wait()),也可以作为控制器使用
|
|
87
|
+
*/
|
|
88
|
+
export interface PTYProcess extends PromiseLike<CommandResult> {
|
|
89
|
+
/** 等待指定文本出现 */
|
|
90
|
+
expect(text: string, options?: {
|
|
91
|
+
timeout?: number;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
/** 发送输入到进程(自动追加换行符) */
|
|
94
|
+
send(input: string): Promise<void>;
|
|
95
|
+
/** 发送原始输入(不追加换行符) */
|
|
96
|
+
sendRaw(input: string): Promise<void>;
|
|
97
|
+
/** 等待命令完成并返回结果 */
|
|
98
|
+
wait(options?: {
|
|
99
|
+
timeout?: number;
|
|
100
|
+
}): Promise<CommandResult>;
|
|
101
|
+
/** 启动命令执行,等待输入完成(不等待命令执行完成) */
|
|
102
|
+
start(): Promise<void>;
|
|
103
|
+
/** 发送 Ctrl+C */
|
|
104
|
+
interrupt(): Promise<void>;
|
|
105
|
+
/** Promise catch 方法 */
|
|
106
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<CommandResult | TResult>;
|
|
107
|
+
/** Promise finally 方法 */
|
|
108
|
+
finally(onfinally?: (() => void) | null): Promise<CommandResult>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* run() 方法选项
|
|
112
|
+
*/
|
|
113
|
+
export interface RunOptions {
|
|
114
|
+
/** 命令超时时间(毫秒),默认:30000 */
|
|
115
|
+
timeout?: number;
|
|
116
|
+
/** 环境变量(可选) */
|
|
117
|
+
env?: Record<string, string>;
|
|
118
|
+
/** 工作目录(可选) */
|
|
119
|
+
cwd?: string;
|
|
120
|
+
/**
|
|
121
|
+
* 标记为交互式命令,使用 PTY 执行
|
|
122
|
+
* 交互式模式支持 expect/send 方法,但 exitCode 不可靠
|
|
123
|
+
*/
|
|
124
|
+
interactive?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* 静默模式:即使在录制模式下也使用 Bun.spawn 执行
|
|
127
|
+
* 用于需要精确解析输出的场景(如 JSON 解析)
|
|
128
|
+
* 注意:此模式下命令不会在录制中显示
|
|
129
|
+
*/
|
|
130
|
+
silent?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* 录制模式:打字速度 (ms/字符)
|
|
133
|
+
* 默认值:80ms,设为 0 则直接写入不打字
|
|
134
|
+
*/
|
|
135
|
+
typingSpeed?: number;
|
|
136
|
+
/**
|
|
137
|
+
* 录制模式:命令执行后暂停时间 (ms)
|
|
138
|
+
* 用于让观众有时间阅读输出
|
|
139
|
+
*/
|
|
140
|
+
pauseAfter?: number;
|
|
141
|
+
/**
|
|
142
|
+
* 录制模式:命令执行前暂停时间 (ms)
|
|
143
|
+
*/
|
|
144
|
+
pauseBefore?: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 插件工厂类型 - 用于为新终端创建插件实例
|
|
148
|
+
*/
|
|
149
|
+
export type PluginFactory<TPlugins = Record<string, unknown>> = (terminal: TerminalAPI) => TPlugins;
|
|
150
|
+
/**
|
|
151
|
+
* 带插件的终端接口
|
|
152
|
+
*/
|
|
153
|
+
export interface TerminalWithPlugins<TPlugins = Record<string, unknown>> extends TerminalAPI {
|
|
154
|
+
/** 插件实例(与主终端相同配置) */
|
|
155
|
+
plugins: TPlugins;
|
|
156
|
+
}
|
|
157
|
+
export interface TerminalAPI {
|
|
158
|
+
/**
|
|
159
|
+
* 执行命令,返回 PTYProcess(可 await 或使用控制器方法)
|
|
160
|
+
*
|
|
161
|
+
* 用法:
|
|
162
|
+
* - 非交互式:直接 await,获取 CommandResult
|
|
163
|
+
* `const result = await terminal.run('echo hello');`
|
|
164
|
+
*
|
|
165
|
+
* - 交互式:不 await,使用控制器方法
|
|
166
|
+
* `const proc = terminal.run('vim file.txt');`
|
|
167
|
+
* `await proc.expect('~');`
|
|
168
|
+
* `await proc.send(':q');`
|
|
169
|
+
* `const result = await proc;`
|
|
170
|
+
*
|
|
171
|
+
* @param command - 要执行的命令
|
|
172
|
+
* @param options - 可选配置
|
|
173
|
+
*/
|
|
174
|
+
run(command: string, options?: RunOptions): PTYProcess;
|
|
175
|
+
/** 发送输入到终端 */
|
|
176
|
+
send(text: string): Promise<void>;
|
|
177
|
+
/** 等待指定文本出现 */
|
|
178
|
+
waitForText(text: string, options?: WaitOptions): Promise<void>;
|
|
179
|
+
/** 获取当前终端输出快照 */
|
|
180
|
+
snapshot(): Promise<string>;
|
|
181
|
+
/** 关闭终端 */
|
|
182
|
+
close(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* 创建新的终端实例(多终端测试)
|
|
185
|
+
* 如果设置了插件工厂,返回的终端会自动携带 plugins 属性
|
|
186
|
+
*/
|
|
187
|
+
create<TPlugins = Record<string, unknown>>(): Promise<TerminalWithPlugins<TPlugins>>;
|
|
188
|
+
/** 检查是否处于录制模式 */
|
|
189
|
+
isRecording?(): boolean;
|
|
190
|
+
/** 检查是否处于 PTY 模式(包括录制模式和 ptyOnly 模式) */
|
|
191
|
+
isPtyMode?(): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* 设置插件工厂(用于 create() 自动注入插件)
|
|
194
|
+
* @internal 由插件系统调用
|
|
195
|
+
*/
|
|
196
|
+
setPluginFactory?<TPlugins>(factory: PluginFactory<TPlugins>): void;
|
|
197
|
+
}
|
|
198
|
+
export interface WaitOptions {
|
|
199
|
+
timeout?: number;
|
|
200
|
+
/**
|
|
201
|
+
* 是否移除 ANSI 转义序列后再匹配文本(录制模式下默认 true)
|
|
202
|
+
* 设为 false 可保留原始输出,用于测试 ANSI 相关功能
|
|
203
|
+
*/
|
|
204
|
+
stripAnsi?: boolean;
|
|
205
|
+
}
|
|
206
|
+
export interface Step {
|
|
207
|
+
id: string;
|
|
208
|
+
type: 'input' | 'wait' | 'assert' | 'step';
|
|
209
|
+
payload: unknown;
|
|
210
|
+
timeout?: number;
|
|
211
|
+
name?: string;
|
|
212
|
+
}
|
|
213
|
+
export interface RunResult {
|
|
214
|
+
id: string;
|
|
215
|
+
suiteId: string;
|
|
216
|
+
caseId: string;
|
|
217
|
+
suiteName: string;
|
|
218
|
+
suitePath: string[];
|
|
219
|
+
caseName: string;
|
|
220
|
+
status: 'pass' | 'fail' | 'skip';
|
|
221
|
+
durationMs: number;
|
|
222
|
+
error?: TestError;
|
|
223
|
+
artifacts: Artifact[];
|
|
224
|
+
recordingPath?: string;
|
|
225
|
+
}
|
|
226
|
+
export interface CommandLog {
|
|
227
|
+
command: string;
|
|
228
|
+
code: number;
|
|
229
|
+
stdout: string;
|
|
230
|
+
stderr: string;
|
|
231
|
+
output: string;
|
|
232
|
+
duration: number;
|
|
233
|
+
}
|
|
234
|
+
export interface TestError {
|
|
235
|
+
message: string;
|
|
236
|
+
stack?: string;
|
|
237
|
+
expected?: unknown;
|
|
238
|
+
actual?: unknown;
|
|
239
|
+
commandLogs?: CommandLog[];
|
|
240
|
+
}
|
|
241
|
+
export interface Artifact {
|
|
242
|
+
id: string;
|
|
243
|
+
runResultId: string;
|
|
244
|
+
type: 'cast' | 'log' | 'snapshot';
|
|
245
|
+
path: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Run status for API endpoint
|
|
249
|
+
*/
|
|
250
|
+
export interface RunStatus {
|
|
251
|
+
runId: string;
|
|
252
|
+
status: 'queued' | 'running' | 'passed' | 'failed';
|
|
253
|
+
totals: {
|
|
254
|
+
passed: number;
|
|
255
|
+
failed: number;
|
|
256
|
+
skipped: number;
|
|
257
|
+
};
|
|
258
|
+
durationMs?: number;
|
|
259
|
+
results?: RunResult[];
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../repterm/src/runner/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAElB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CAElB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxG;AAED,MAAM,WAAW,S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