@midscene/test 1.17.5 → 1.17.7
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/dist/es/cli/index.mjs +73 -39
- package/dist/es/cli/index.mjs.map +1 -1
- package/dist/es/index.mjs +5 -0
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/test-cli.mjs +76 -40
- package/dist/es/test-cli.mjs.map +1 -1
- package/dist/lib/cli/index.js +73 -39
- package/dist/lib/cli/index.js.map +1 -1
- package/dist/lib/index.js +5 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/test-cli.js +76 -40
- package/dist/lib/test-cli.js.map +1 -1
- package/dist/templates/test/android/README.md +1 -1
- package/dist/templates/test/android/README.zh.md +1 -1
- package/dist/templates/test/android/gitignore +0 -1
- package/dist/templates/test/computer/README.md +1 -1
- package/dist/templates/test/computer/README.zh.md +1 -1
- package/dist/templates/test/computer/gitignore +0 -1
- package/dist/templates/test/harmony/README.md +1 -1
- package/dist/templates/test/harmony/README.zh.md +1 -1
- package/dist/templates/test/harmony/gitignore +0 -1
- package/dist/templates/test/ios/README.md +1 -1
- package/dist/templates/test/ios/README.zh.md +1 -1
- package/dist/templates/test/ios/gitignore +0 -1
- package/dist/templates/test/web/README.md +1 -1
- package/dist/templates/test/web/README.zh.md +1 -1
- package/dist/templates/test/web/gitignore +0 -1
- package/dist/types/cli/index.d.ts +2 -1
- package/package.json +13 -13
package/dist/es/index.mjs
CHANGED
|
@@ -323,6 +323,9 @@ function collectWorkflowDocument(source, options) {
|
|
|
323
323
|
cases
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
|
+
function renderTestBadge(summary) {
|
|
327
|
+
return ``;
|
|
328
|
+
}
|
|
326
329
|
const result_markdown_text = (value)=>value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll('|', '|').replaceAll('[', '[').replaceAll(']', ']').replaceAll('*', '*').replaceAll('_', '_').replaceAll('`', '`').replaceAll('\\', '\').replace(/[\r\n]+/g, ' ');
|
|
327
330
|
const duration = (ms)=>{
|
|
328
331
|
const seconds = Math.round(ms / 1000);
|
|
@@ -335,6 +338,8 @@ function renderTestResultMarkdown(dump, options = {}) {
|
|
|
335
338
|
const lines = [
|
|
336
339
|
'## Midscene Test',
|
|
337
340
|
'',
|
|
341
|
+
renderTestBadge(summary),
|
|
342
|
+
'',
|
|
338
343
|
`${outcome} · ${duration(dump.durationMs)}`,
|
|
339
344
|
''
|
|
340
345
|
];
|
package/dist/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/engine/case-runner.ts","../../src/engine/document-runtime.ts","../../src/engine/registry.ts","../../src/engine/run-workflow-document.ts","../../src/node/define-node.ts","../../src/parser/identifiers.ts","../../src/parser/normalize.ts","../../src/parser/source.ts","../../src/parser/variables.ts","../../src/parser/collect.ts","../../src/report/result-markdown.ts"],"sourcesContent":["import {\n CaseRunner as CoreCaseRunner,\n createCaseRunner as coreCreateCaseRunner,\n} from '@midscene/core/internal/test-runner';\nimport type { NodeDefinition } from '../node/types';\nimport type { CaseInput } from '../parser/types';\nimport type { NodeRegistry } from './registry';\nimport type { CaseRunResult, CaseRunnerOptions } from './types';\n\nexport type CaseRunner<TContext = undefined> = Omit<\n CoreCaseRunner<TContext>,\n 'run' | 'register' | 'registry'\n> & {\n readonly registry: NodeRegistry;\n register<TInput, TData>(\n node: NodeDefinition<TInput, TData, TContext>,\n ): CaseRunner<TContext>;\n run(input: CaseInput): Promise<CaseRunResult>;\n};\nexport const CaseRunner: {\n new <TContext = undefined>(\n options?: CaseRunnerOptions<TContext>,\n ): CaseRunner<TContext>;\n} = CoreCaseRunner;\nexport const createCaseRunner: <TContext = undefined>(\n options?: CaseRunnerOptions<TContext>,\n) => CaseRunner<TContext> = coreCreateCaseRunner;\n","import { createDocumentRuntime as coreCreateDocumentRuntime } from '@midscene/core/internal/test-runner';\nimport type { CollectedWorkflowDocument } from '../parser/types';\nimport type {\n CreateDocumentRuntimeOptions,\n WorkflowDocumentRuntime,\n} from './types';\n\nexport const createDocumentRuntime: <TContext = undefined>(\n document: CollectedWorkflowDocument,\n options: CreateDocumentRuntimeOptions<TContext>,\n) => WorkflowDocumentRuntime<TContext> = coreCreateDocumentRuntime;\n","import { NodeRegistry as CoreNodeRegistry } from '@midscene/core/internal/test-runner';\nimport type { NodeDefinition } from '../node/types';\n\nexport type NodeRegistry = Omit<\n CoreNodeRegistry,\n 'get' | 'require' | 'register' | 'definitions'\n> & {\n get(name: string): NodeDefinition<any, any> | undefined;\n require(name: string): NodeDefinition<any, any>;\n register<TInput, TData>(node: NodeDefinition<TInput, TData>): NodeRegistry;\n definitions(): readonly NodeDefinition<any, any, any>[];\n};\nexport const NodeRegistry: {\n new (nodes?: readonly NodeDefinition<any, any>[]): NodeRegistry;\n} = CoreNodeRegistry;\n","import { runWorkflowDocument as coreRunWorkflowDocument } from '@midscene/core/internal/test-runner';\nimport type { CollectedWorkflowDocument } from '../parser/types';\nimport type {\n RunWorkflowDocumentOptions,\n WorkflowDocumentExecutionResult,\n} from './types';\n\nexport const runWorkflowDocument: <TContext = undefined>(\n document: CollectedWorkflowDocument,\n options: RunWorkflowDocumentOptions<TContext>,\n) => Promise<WorkflowDocumentExecutionResult> = coreRunWorkflowDocument;\n","import { defineNode as coreDefineNode } from '@midscene/core/internal/test-runner';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\n// A type-only facade: validation and execution still belong to the shared kernel.\ninterface DefineNativeNode {\n <TSchema extends NodeInputSchema, TData = unknown, TContext = unknown>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n ): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n <TInput = unknown, TData = unknown, TContext = unknown>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n ): NodeDefinition<TInput, TData, TContext>;\n}\nexport const defineNode: DefineNativeNode = coreDefineNode;\n","import { createHash } from 'node:crypto';\n\n/** Internal invocation identity keeps repeated legacy files distinct. */\nexport const createCaseInvocationId = (\n projectId: string,\n sourcePath: string,\n caseIndex: number,\n invocationIndex = 0,\n): string =>\n createHash('sha256')\n .update(\n JSON.stringify([\n projectId,\n sourcePath,\n caseIndex,\n ...(invocationIndex ? [invocationIndex] : []),\n ]),\n )\n .digest('hex');\n\nexport const createDocumentInvocationId = (\n projectId: string,\n sourcePath: string,\n invocationIndex = 0,\n): string =>\n createHash('sha256')\n .update(\n JSON.stringify([\n projectId,\n sourcePath,\n ...(invocationIndex ? [invocationIndex] : []),\n ]),\n )\n .digest('hex');\n","import {\n type ResolveNodeForNormalization,\n normalizeStep as coreNormalizeStep,\n normalizeSteps as coreNormalizeSteps,\n} from '@midscene/core/internal/test-runner';\nimport type { NormalizedStep } from './types';\nexport type { ResolveNodeForNormalization } from '@midscene/core/internal/test-runner';\n\nexport const normalizeStep: (\n value: unknown,\n index?: number,\n resolveNode?: ResolveNodeForNormalization,\n) => NormalizedStep = coreNormalizeStep;\nexport const normalizeSteps: (\n values: unknown,\n resolveNode?: ResolveNodeForNormalization,\n) => NormalizedStep[] = coreNormalizeSteps;\n","import type { TestRunReportValue } from '@midscene/core';\nimport {\n isReportSecretKey,\n sanitizeReportText,\n} from '@midscene/core/internal/test-runner';\nimport { JSON_SCHEMA, load } from 'js-yaml';\n\ninterface SourceNode {\n start: number;\n end: number;\n value: unknown;\n children: SourceNode[];\n kind: string | null;\n}\n\n/** Keep author formatting while redacting values by parsed YAML keys, including aliases. */\nexport function parseWorkflowSource(source: string): {\n parsed: unknown;\n sourceYaml: TestRunReportValue;\n locate(\n path: readonly (string | number)[],\n ): { line: number; column: number } | undefined;\n} {\n const stack: SourceNode[] = [];\n const nodes: SourceNode[] = [];\n const sensitiveNodes = new Set<SourceNode>();\n const sensitiveValues = new Set<unknown>();\n const redactedPaths = new Set<string>();\n // js-yaml removes the BOM before reporting source positions.\n const sourceOffset = source.charCodeAt(0) === 0xfeff ? 1 : 0;\n const parsed = load(source, {\n schema: JSON_SCHEMA,\n listener(event, state) {\n if (event === 'open') {\n stack.push({\n start: state.position + sourceOffset,\n end: 0,\n value: null,\n children: [],\n kind: null,\n });\n return;\n }\n const node = stack.pop()!;\n node.end = state.position + sourceOffset;\n node.value = state.result;\n node.kind = state.kind;\n stack.at(-1)?.children.push(node);\n nodes.push(node);\n if (state.kind !== 'mapping') return;\n for (let index = 0; index < node.children.length; index += 2) {\n const key = node.children[index].value;\n const value = node.children[index + 1];\n if (typeof key !== 'string' || !isReportSecretKey(key) || !value)\n continue;\n sensitiveNodes.add(value);\n if (value.value !== null) sensitiveValues.add(value.value);\n redactedPaths.add(`$..[${JSON.stringify(key)}]`);\n }\n },\n });\n // Redact the definition as well when a secret value refers to a YAML anchor.\n const ranges = nodes\n .filter(\n (node) => sensitiveNodes.has(node) || sensitiveValues.has(node.value),\n )\n .sort((left, right) => left.start - right.start || right.end - left.end);\n let offset = 0;\n let redacted = '';\n for (const range of ranges) {\n if (range.start < offset) continue;\n const text = source.slice(range.start, range.end);\n const leading = text.match(/^\\s*/)?.[0] ?? '';\n const trailing = text.slice(leading.length).match(/\\s*$/)?.[0] ?? '';\n redacted += `${source.slice(offset, range.start)}${leading}\"[REDACTED]\"${trailing}`;\n offset = range.end;\n }\n redacted += source.slice(offset);\n const value = sanitizeReportText(redacted, 64 * 1024);\n return {\n parsed,\n locate(path) {\n let node = nodes.at(-1);\n for (const part of path) {\n if (!node) return undefined;\n // js-yaml can emit a wrapper around a block collection.\n while (\n node.children.length === 1 &&\n node.children[0].value === node.value\n )\n node = node.children[0];\n if (typeof part === 'number' && node.kind === 'sequence')\n node = node.children[part];\n else if (typeof part === 'string' && node.kind === 'mapping') {\n const children = node.children;\n node = undefined;\n for (let index = 0; index < children.length; index += 2)\n if (children[index].value === part) {\n node = children[index + 1];\n break;\n }\n } else return undefined;\n }\n if (!node) return undefined;\n let start = node.start;\n while (start < node.end) {\n if (/\\s/.test(source[start])) start++;\n else if (source[start] === '#') {\n const end = source.indexOf('\\n', start);\n if (end < 0) return undefined;\n start = end + 1;\n } else break;\n }\n const prefix = source.slice(0, start).split(/\\r\\n|\\r|\\n/);\n return { line: prefix.length, column: prefix.at(-1)!.length + 1 };\n },\n sourceYaml: {\n value,\n ...(redactedPaths.size ? { redactedPaths: [...redactedPaths] } : {}),\n ...(value !== redacted ? { truncatedPaths: ['$'] } : {}),\n },\n };\n}\n","import type { JsonValue } from '../cli/test-project';\nimport { WorkflowParseError } from '../errors';\n\nexport interface VariableResolutionLocation {\n projectName: string;\n sourcePath: string;\n phase: 'beforeAll' | 'beforeEach' | 'steps' | 'afterEach' | 'afterAll';\n stepIndex: number;\n caseIndex?: number;\n}\n\nexport interface ResolveWorkflowVariablesOptions {\n variables?: Readonly<Record<string, JsonValue>>;\n env?: Readonly<NodeJS.ProcessEnv>;\n location: VariableResolutionLocation;\n}\n\nconst interpolationExpression =\n /\\$\\{\\{([A-Za-z_][A-Za-z0-9_]*)\\}\\}|\\$\\{([^{}]+)\\}/g;\nconst exactEnvExpression = /^\\$\\{\\{([A-Za-z_][A-Za-z0-9_]*)\\}\\}$/;\nconst exactProjectExpression = /^\\$\\{([^{}]+)\\}$/;\n\nconst missingVariable = (\n kind: 'environment' | 'project',\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): never => {\n throw new WorkflowParseError(\n `Undefined ${kind} variable \"${name}\" in ${options.location.sourcePath}.`,\n { ...options.location, variable: name, variableKind: kind },\n );\n};\n\nconst projectVariable = (\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): JsonValue => {\n if (!Object.hasOwn(options.variables ?? {}, name)) {\n return missingVariable('project', name, options);\n }\n return options.variables![name];\n};\n\nconst environmentVariable = (\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): string => {\n const value = options.env?.[name];\n if (value === undefined) return missingVariable('environment', name, options);\n return value;\n};\n\nconst interpolationValue = (\n name: string,\n value: JsonValue,\n options: ResolveWorkflowVariablesOptions,\n): string => {\n if (typeof value === 'object' && value !== null) {\n throw new WorkflowParseError(\n `Project variable \"${name}\" must be a primitive when embedded in a string.`,\n {\n ...options.location,\n variable: name,\n variableKind: 'project',\n },\n );\n }\n return String(value);\n};\n\nconst resolveString = (\n value: string,\n options: ResolveWorkflowVariablesOptions,\n): JsonValue => {\n const exactEnv = exactEnvExpression.exec(value);\n if (exactEnv) return environmentVariable(exactEnv[1], options);\n const exactProject = exactProjectExpression.exec(value);\n if (exactProject) return projectVariable(exactProject[1], options);\n\n return value.replace(\n interpolationExpression,\n (_match, environmentName: string | undefined, projectName: string) =>\n environmentName\n ? environmentVariable(environmentName, options)\n : interpolationValue(\n projectName,\n projectVariable(projectName, options),\n options,\n ),\n );\n};\n\nexport const resolveWorkflowVariables = (\n value: unknown,\n options: ResolveWorkflowVariablesOptions,\n): unknown => {\n if (typeof value === 'string') return resolveString(value, options);\n if (Array.isArray(value)) {\n return value.map((child) => resolveWorkflowVariables(child, options));\n }\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n resolveWorkflowVariables(child, options),\n ]),\n );\n }\n return value;\n};\n","import { readFileSync } from 'node:fs';\nimport { sep } from 'node:path';\nimport { classifyWorkflowDocumentFormat } from '@midscene/core/internal/test-runner';\nimport type { JsonValue } from '../cli/test-project';\nimport { WorkflowParseError } from '../errors';\nimport type { NodeDefinition } from '../node/types';\nimport {\n createCaseInvocationId,\n createDocumentInvocationId,\n} from './identifiers';\nimport { normalizeSteps } from './normalize';\nimport { parseWorkflowSource } from './source';\nimport type {\n CollectedCase,\n CollectedWorkflowDocument,\n WorkflowDocumentSource,\n} from './types';\nimport { resolveWorkflowVariables } from './variables';\n\nexport interface CollectWorkflowDocumentOptions {\n resolveNode(name: string): NodeDefinition<any, any> | undefined;\n variables?: Readonly<Record<string, JsonValue>>;\n env?: Readonly<NodeJS.ProcessEnv>;\n}\n\nconst isMapping = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport class NativeWorkflowFormatError extends WorkflowParseError {\n readonly actualFormat: 'legacy' | 'legacy-batch' | 'mixed';\n\n constructor(\n actualFormat: 'legacy' | 'legacy-batch' | 'mixed',\n sourcePath: string,\n ) {\n super(\n actualFormat === 'legacy'\n ? `Legacy tasks/flow YAML is not supported by midscene-test: ${sourcePath}. Run it with \\`midscene ${sourcePath}\\`, or migrate the file to cases/steps.`\n : actualFormat === 'legacy-batch'\n ? `Legacy YAML batch configuration is not a midscene-test workflow document: ${sourcePath}. Run it with \\`midscene --config ${sourcePath}\\`, or migrate it to a native project config.`\n : `A workflow file cannot mix legacy tasks/flow with native cases/steps or lifecycle hooks: ${sourcePath}. Keep the formats in separate files and run each file with its matching command.`,\n { sourcePath, actualFormat, expectedFormat: 'native' },\n );\n this.actualFormat = actualFormat;\n }\n}\n\nconst rejectUnknownKeys = (\n value: Record<string, unknown>,\n allowed: readonly string[],\n label: string,\n) => {\n const allowedSet = new Set(allowed);\n const unknown = Object.keys(value).filter((key) => !allowedSet.has(key));\n if (unknown.length) {\n throw new WorkflowParseError(\n `${label} has unsupported field \"${unknown[0]}\".`,\n { field: unknown[0] },\n );\n }\n};\n\nexport const createCaseId = (\n projectId: string,\n sourcePath: string,\n caseIndex: number,\n): string => createCaseInvocationId(projectId, sourcePath, caseIndex);\n\nexport const createWorkflowDocumentId = (\n projectId: string,\n sourcePath: string,\n): string => createDocumentInvocationId(projectId, sourcePath);\n\nexport function collectWorkflowDocument(\n source: WorkflowDocumentSource,\n options: CollectWorkflowDocumentOptions,\n): CollectedWorkflowDocument {\n let snapshot: ReturnType<typeof parseWorkflowSource>;\n try {\n snapshot = parseWorkflowSource(readFileSync(source.absolutePath, 'utf8'));\n } catch (error) {\n throw new WorkflowParseError(\n `Failed to parse workflow document \"${source.sourcePath}\".`,\n { sourcePath: source.sourcePath },\n error,\n );\n }\n const { parsed, sourceYaml } = snapshot;\n\n if (!isMapping(parsed)) {\n throw new WorkflowParseError('Workflow document must be a mapping.');\n }\n const format = classifyWorkflowDocumentFormat(parsed);\n if (format === 'legacy' || format === 'legacy-batch' || format === 'mixed') {\n throw new NativeWorkflowFormatError(format, source.sourcePath);\n }\n rejectUnknownKeys(\n parsed,\n ['beforeAll', 'beforeEach', 'cases', 'afterEach', 'afterAll'],\n 'Workflow document',\n );\n if (!Array.isArray(parsed.cases) || parsed.cases.length === 0) {\n throw new WorkflowParseError(\n 'Workflow document must contain a non-empty cases array.',\n );\n }\n\n const sourcePath = source.sourcePath.split(sep).join('/');\n const resolveStepVariables = (\n step: ReturnType<typeof normalizeSteps>[number],\n phase: 'beforeAll' | 'beforeEach' | 'steps' | 'afterEach' | 'afterAll',\n stepIndex: number,\n caseIndex?: number,\n ) => ({\n ...step,\n meta: {\n ...step.meta,\n sourceLocation: snapshot.locate(\n phase === 'steps'\n ? ['cases', caseIndex!, 'steps', stepIndex]\n : [phase, stepIndex],\n ),\n },\n templateInput: step.input,\n input: resolveWorkflowVariables(step.input, {\n variables: options.variables,\n env: options.env ?? process.env,\n location: {\n projectName: source.projectName ?? source.projectId,\n sourcePath,\n phase,\n stepIndex,\n ...(caseIndex === undefined ? {} : { caseIndex }),\n },\n }) as typeof step.input,\n });\n const normalizeLifecycle = (\n phase: 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll',\n ) => {\n const value = parsed[phase];\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new WorkflowParseError(\n `Workflow document ${phase} must be an array.`,\n { phase },\n );\n }\n return normalizeSteps(value, options.resolveNode).map(\n (normalized, stepIndex) => {\n const resolved = options.resolveNode(normalized.node);\n if (!resolved) {\n throw new WorkflowParseError(\n `Workflow document ${phase} step ${stepIndex + 1} references unknown node \"${normalized.node}\".`,\n { phase, stepIndex, node: normalized.node },\n );\n }\n return resolveStepVariables(normalized, phase, stepIndex);\n },\n );\n };\n const lifecycle = {\n beforeAll: normalizeLifecycle('beforeAll'),\n beforeEach: normalizeLifecycle('beforeEach'),\n afterEach: normalizeLifecycle('afterEach'),\n afterAll: normalizeLifecycle('afterAll'),\n };\n const ids = new Set<string>();\n const cases: CollectedCase[] = parsed.cases.map((definition, caseIndex) => {\n if (!isMapping(definition)) {\n throw new WorkflowParseError(`Case ${caseIndex + 1} must be a mapping.`, {\n caseIndex,\n });\n }\n rejectUnknownKeys(\n definition,\n ['name', 'tags', 'steps'],\n `Case ${caseIndex + 1}`,\n );\n if (\n typeof definition.name !== 'string' ||\n definition.name.trim().length === 0\n ) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} name must be a non-empty string.`,\n { caseIndex },\n );\n }\n if (!Array.isArray(definition.steps) || definition.steps.length === 0) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} steps must be a non-empty array.`,\n { caseIndex },\n );\n }\n const tags = definition.tags ?? [];\n if (\n !Array.isArray(tags) ||\n tags.some((tag) => typeof tag !== 'string' || tag.trim().length === 0)\n ) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} tags must be an array of non-empty strings.`,\n { caseIndex },\n );\n }\n\n const steps = normalizeSteps(definition.steps, options.resolveNode).map(\n (normalized, stepIndex) => {\n if (!options.resolveNode(normalized.node)) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} step ${stepIndex + 1} references unknown node \"${normalized.node}\".`,\n { caseIndex, stepIndex, node: normalized.node },\n );\n }\n return resolveStepVariables(normalized, 'steps', stepIndex, caseIndex);\n },\n );\n const caseId = createCaseId(source.projectId, sourcePath, caseIndex);\n if (ids.has(caseId)) {\n throw new WorkflowParseError(`Case id collision: ${caseId}.`, {\n caseId,\n });\n }\n ids.add(caseId);\n\n return {\n caseId,\n projectId: source.projectId,\n sourcePath,\n caseIndex,\n definition: {\n name: definition.name,\n tags: tags as string[],\n steps,\n },\n };\n });\n\n return {\n documentId: createWorkflowDocumentId(source.projectId, sourcePath),\n projectId: source.projectId,\n sourcePath,\n sourceYaml,\n lifecycle,\n cases,\n } satisfies CollectedWorkflowDocument;\n}\n","import { writeFile } from 'node:fs/promises';\nimport { dirname, join, relative, sep } from 'node:path';\nimport type {\n TestRunReportDump,\n TestRunReportSourceIndex,\n TestRunReportStep,\n} from '@midscene/core';\nimport type { TestProjectRunResult } from '../cli/types';\nimport { buildTestRunReportDump } from './test-run-report';\n\nconst text = (value: string): string =>\n value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll('|', '|')\n .replaceAll('[', '[')\n .replaceAll(']', ']')\n .replaceAll('*', '*')\n .replaceAll('_', '_')\n .replaceAll('`', '`')\n .replaceAll('\\\\', '\')\n .replace(/[\\r\\n]+/g, ' ');\n\nconst duration = (ms: number): string => {\n const seconds = Math.round(ms / 1000);\n return seconds < 60\n ? `${seconds}s`\n : `${Math.floor(seconds / 60)}m ${seconds % 60}s`;\n};\nconst href = (from: string, target: string): string =>\n relative(dirname(from), target).split(sep).map(encodeURIComponent).join('/');\n\nexport interface TestResultMarkdownOptions {\n /** Relative or hosted URL of the HTML report. */\n reportHref?: string;\n}\n\n/** Render the same sanitized execution facts used by the HTML report. */\nexport function renderTestResultMarkdown(\n dump: TestRunReportDump,\n options: TestResultMarkdownOptions = {},\n): string {\n const { summary } = dump;\n const outcome =\n dump.status === 'success'\n ? `✅ **${summary.passed}/${summary.total} passed**`\n : `❌ **${summary.failed} failed** · ${summary.passed} passed · ${summary.notRun} not run`;\n const lines = [\n '## Midscene Test',\n '',\n `${outcome} · ${duration(dump.durationMs)}`,\n '',\n ];\n if (summary.filtered) lines.push(`**Filtered:** ${summary.filtered}`, '');\n const infrastructure = [\n summary.collectionErrors\n ? `${summary.collectionErrors} collection errors`\n : '',\n summary.documentFailures\n ? `${summary.documentFailures} document failures`\n : '',\n summary.projectFailures\n ? `${summary.projectFailures} project failures`\n : '',\n ].filter(Boolean);\n if (infrastructure.length)\n lines.push(`**Infrastructure:** ${infrastructure.join(' · ')}`, '');\n const groups: { name: string; rows: string[] }[] = [];\n const errors: string[] = [];\n const recordSteps = (label: string, steps: readonly TestRunReportStep[]) => {\n for (const step of steps) {\n if (step.status === 'failed')\n errors.push(\n `${label} / ${step.node}: ${step.error?.message ?? 'Step failed'}`,\n );\n }\n };\n for (const project of dump.projects) {\n if (project.lifecycle?.setupError)\n errors.push(`${project.name}: ${project.lifecycle.setupError.message}`);\n for (const error of project.lifecycle?.teardownErrors ?? [])\n errors.push(`${project.name}: ${error.message}`);\n for (const error of project.collectionErrors)\n errors.push(\n `${project.name} / ${error.sourcePath}: ${error.error.message}`,\n );\n for (const document of project.documents) {\n const name = document.sourcePath\n .replace(/\\\\/g, '/')\n .replace(/\\.(?:yaml|yml)$/, '');\n const group = {\n name: dump.projects.length > 1 ? `${project.name} / ${name}` : name,\n rows: [] as string[],\n };\n groups.push(group);\n recordSteps(`${project.name} / ${document.sourcePath}`, [\n ...document.beforeAll,\n ...document.afterAll,\n ]);\n for (const error of document.teardownErrors ?? [])\n errors.push(`${document.sourcePath}: ${error.message}`);\n for (const failure of document.hostErrors ?? [])\n errors.push(\n `${document.sourcePath} / ${failure.phase}: ${failure.error.message}`,\n );\n for (const testCase of document.cases) {\n group.rows.push(\n ` - ${testCase.status === 'success' ? '✅' : testCase.status === 'not-run' ? '⏭️' : '❌'} ${text(testCase.name)}`,\n );\n }\n }\n }\n for (const diagnostic of dump.diagnostics ?? []) {\n if (diagnostic.level === 'error') errors.push(diagnostic.message);\n }\n if (errors.length)\n lines.push(\n '### Execution errors',\n '',\n ...errors.map((error) => `- ${text(error)}`),\n '',\n );\n for (const group of groups) {\n if (group.rows.length) lines.push(`- ${text(group.name)}`, ...group.rows);\n }\n if (!groups.some((group) => group.rows.length))\n lines.push('No cases were reported.');\n if (options.reportHref)\n lines.push(\n '',\n `[Open the Midscene Test report ↗](<${options.reportHref}>)`,\n );\n return `${lines.join('\\n')}\\n`;\n}\n\nconst emptyIndex = (): TestRunReportSourceIndex => ({\n sources: [],\n metrics: {\n modelCallCount: 0,\n modelTimeMs: 0,\n promptTokens: 0,\n cachedInputTokens: 0,\n completionTokens: 0,\n totalTokens: 0,\n },\n});\n\n/** Write a per-run Markdown artifact even when HTML publication fails or is disabled. */\nexport async function writeTestResultMarkdown(\n result: TestProjectRunResult,\n index: TestRunReportSourceIndex = emptyIndex(),\n): Promise<string> {\n const output = join(dirname(result.summaryPath), 'result.md');\n const dump = buildTestRunReportDump(result, index);\n await writeFile(\n output,\n renderTestResultMarkdown(dump, {\n ...(result.reportPath\n ? { reportHref: href(output, result.reportPath) }\n : {}),\n }),\n );\n return output;\n}\n"],"names":["CaseRunner","CoreCaseRunner","createCaseRunner","coreCreateCaseRunner","createDocumentRuntime","coreCreateDocumentRuntime","NodeRegistry","CoreNodeRegistry","runWorkflowDocument","coreRunWorkflowDocument","defineNode","coreDefineNode","createCaseInvocationId","projectId","sourcePath","caseIndex","invocationIndex","createHash","JSON","createDocumentInvocationId","normalizeStep","coreNormalizeStep","normalizeSteps","coreNormalizeSteps","parseWorkflowSource","source","stack","nodes","sensitiveNodes","Set","sensitiveValues","redactedPaths","sourceOffset","parsed","load","JSON_SCHEMA","event","state","node","index","key","value","isReportSecretKey","ranges","left","right","offset","redacted","range","text","leading","trailing","sanitizeReportText","path","part","children","undefined","start","end","prefix","interpolationExpression","exactEnvExpression","exactProjectExpression","missingVariable","kind","name","options","WorkflowParseError","projectVariable","Object","environmentVariable","interpolationValue","String","resolveString","exactEnv","exactProject","_match","environmentName","projectName","resolveWorkflowVariables","Array","child","isMapping","NativeWorkflowFormatError","actualFormat","rejectUnknownKeys","allowed","label","allowedSet","unknown","createCaseId","createWorkflowDocumentId","collectWorkflowDocument","snapshot","readFileSync","error","sourceYaml","format","classifyWorkflowDocumentFormat","sep","resolveStepVariables","step","phase","stepIndex","process","normalizeLifecycle","normalized","resolved","lifecycle","ids","cases","definition","tags","tag","steps","caseId","duration","ms","seconds","Math","href","from","target","relative","dirname","encodeURIComponent","renderTestResultMarkdown","dump","summary","outcome","lines","infrastructure","Boolean","groups","errors","recordSteps","project","document","group","failure","testCase","diagnostic","emptyIndex","writeTestResultMarkdown","result","output","join","buildTestRunReportDump","writeFile"],"mappings":";;;;;;;AAmBO,MAAMA,yBAITC;AACG,MAAMC,+BAEeC;ACnBrB,MAAMC,yCAG4BC;ACElC,MAAMC,wBAETC;ACPG,MAAMC,4CAGmCC;ACQzC,MAAMC,yBAA+BC;ACfrC,MAAMC,yBAAyB,CACpCC,WACAC,YACAC,WACAC,kBAAkB,CAAC,GAEnBC,WAAW,UACR,MAAM,CACLC,KAAK,SAAS,CAAC;QACbL;QACAC;QACAC;WACIC,kBAAkB;YAACA;SAAgB,GAAG,EAAE;KAC7C,GAEF,MAAM,CAAC;AAEL,MAAMG,6BAA6B,CACxCN,WACAC,YACAE,kBAAkB,CAAC,GAEnBC,WAAW,UACR,MAAM,CACLC,KAAK,SAAS,CAAC;QACbL;QACAC;WACIE,kBAAkB;YAACA;SAAgB,GAAG,EAAE;KAC7C,GAEF,MAAM,CAAC;ACzBL,MAAMI,0BAISC;AACf,MAAMC,2BAGWC;ACAjB,SAASC,oBAAoBC,MAAc;IAOhD,MAAMC,QAAsB,EAAE;IAC9B,MAAMC,QAAsB,EAAE;IAC9B,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,kBAAkB,IAAID;IAC5B,MAAME,gBAAgB,IAAIF;IAE1B,MAAMG,eAAeP,AAAyB,WAAzBA,OAAO,UAAU,CAAC,KAAgB,IAAI;IAC3D,MAAMQ,SAASC,KAAKT,QAAQ;QAC1B,QAAQU;QACR,UAASC,KAAK,EAAEC,KAAK;YACnB,IAAID,AAAU,WAAVA,OAAkB,YACpBV,MAAM,IAAI,CAAC;gBACT,OAAOW,MAAM,QAAQ,GAAGL;gBACxB,KAAK;gBACL,OAAO;gBACP,UAAU,EAAE;gBACZ,MAAM;YACR;YAGF,MAAMM,OAAOZ,MAAM,GAAG;YACtBY,KAAK,GAAG,GAAGD,MAAM,QAAQ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EhE,OAAO,GAAGgE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;AAChC;AAEA,MAAMY,aAAa,IAAiC;QAClD,SAAS,EAAE;QACX,SAAS;YACP,gBAAgB;YAChB,aAAa;YACb,cAAc;YACd,mBAAmB;YACnB,kBAAkB;YAClB,aAAa;QACf;IACF;AAGO,eAAeC,wBACpBC,MAA4B,EAC5BzG,QAAkCuG,YAAY;IAE9C,MAAMG,SAASC,KAAKtB,QAAQoB,OAAO,WAAW,GAAG;IACjD,MAAMjB,OAAOoB,uBAAuBH,QAAQzG;IAC5C,MAAM6G,UACJH,QACAnB,yBAAyBC,MAAM;QAC7B,GAAIiB,OAAO,UAAU,GACjB;YAAE,YAAYxB,KAAKyB,QAAQD,OAAO,UAAU;QAAE,IAC9C,CAAC,CAAC;IACR;IAEF,OAAOC;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/engine/case-runner.ts","../../src/engine/document-runtime.ts","../../src/engine/registry.ts","../../src/engine/run-workflow-document.ts","../../src/node/define-node.ts","../../src/parser/identifiers.ts","../../src/parser/normalize.ts","../../src/parser/source.ts","../../src/parser/variables.ts","../../src/parser/collect.ts","../../src/report/badge.ts","../../src/report/result-markdown.ts"],"sourcesContent":["import {\n CaseRunner as CoreCaseRunner,\n createCaseRunner as coreCreateCaseRunner,\n} from '@midscene/core/internal/test-runner';\nimport type { NodeDefinition } from '../node/types';\nimport type { CaseInput } from '../parser/types';\nimport type { NodeRegistry } from './registry';\nimport type { CaseRunResult, CaseRunnerOptions } from './types';\n\nexport type CaseRunner<TContext = undefined> = Omit<\n CoreCaseRunner<TContext>,\n 'run' | 'register' | 'registry'\n> & {\n readonly registry: NodeRegistry;\n register<TInput, TData>(\n node: NodeDefinition<TInput, TData, TContext>,\n ): CaseRunner<TContext>;\n run(input: CaseInput): Promise<CaseRunResult>;\n};\nexport const CaseRunner: {\n new <TContext = undefined>(\n options?: CaseRunnerOptions<TContext>,\n ): CaseRunner<TContext>;\n} = CoreCaseRunner;\nexport const createCaseRunner: <TContext = undefined>(\n options?: CaseRunnerOptions<TContext>,\n) => CaseRunner<TContext> = coreCreateCaseRunner;\n","import { createDocumentRuntime as coreCreateDocumentRuntime } from '@midscene/core/internal/test-runner';\nimport type { CollectedWorkflowDocument } from '../parser/types';\nimport type {\n CreateDocumentRuntimeOptions,\n WorkflowDocumentRuntime,\n} from './types';\n\nexport const createDocumentRuntime: <TContext = undefined>(\n document: CollectedWorkflowDocument,\n options: CreateDocumentRuntimeOptions<TContext>,\n) => WorkflowDocumentRuntime<TContext> = coreCreateDocumentRuntime;\n","import { NodeRegistry as CoreNodeRegistry } from '@midscene/core/internal/test-runner';\nimport type { NodeDefinition } from '../node/types';\n\nexport type NodeRegistry = Omit<\n CoreNodeRegistry,\n 'get' | 'require' | 'register' | 'definitions'\n> & {\n get(name: string): NodeDefinition<any, any> | undefined;\n require(name: string): NodeDefinition<any, any>;\n register<TInput, TData>(node: NodeDefinition<TInput, TData>): NodeRegistry;\n definitions(): readonly NodeDefinition<any, any, any>[];\n};\nexport const NodeRegistry: {\n new (nodes?: readonly NodeDefinition<any, any>[]): NodeRegistry;\n} = CoreNodeRegistry;\n","import { runWorkflowDocument as coreRunWorkflowDocument } from '@midscene/core/internal/test-runner';\nimport type { CollectedWorkflowDocument } from '../parser/types';\nimport type {\n RunWorkflowDocumentOptions,\n WorkflowDocumentExecutionResult,\n} from './types';\n\nexport const runWorkflowDocument: <TContext = undefined>(\n document: CollectedWorkflowDocument,\n options: RunWorkflowDocumentOptions<TContext>,\n) => Promise<WorkflowDocumentExecutionResult> = coreRunWorkflowDocument;\n","import { defineNode as coreDefineNode } from '@midscene/core/internal/test-runner';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\n// A type-only facade: validation and execution still belong to the shared kernel.\ninterface DefineNativeNode {\n <TSchema extends NodeInputSchema, TData = unknown, TContext = unknown>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n ): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n <TInput = unknown, TData = unknown, TContext = unknown>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n ): NodeDefinition<TInput, TData, TContext>;\n}\nexport const defineNode: DefineNativeNode = coreDefineNode;\n","import { createHash } from 'node:crypto';\n\n/** Internal invocation identity keeps repeated legacy files distinct. */\nexport const createCaseInvocationId = (\n projectId: string,\n sourcePath: string,\n caseIndex: number,\n invocationIndex = 0,\n): string =>\n createHash('sha256')\n .update(\n JSON.stringify([\n projectId,\n sourcePath,\n caseIndex,\n ...(invocationIndex ? [invocationIndex] : []),\n ]),\n )\n .digest('hex');\n\nexport const createDocumentInvocationId = (\n projectId: string,\n sourcePath: string,\n invocationIndex = 0,\n): string =>\n createHash('sha256')\n .update(\n JSON.stringify([\n projectId,\n sourcePath,\n ...(invocationIndex ? [invocationIndex] : []),\n ]),\n )\n .digest('hex');\n","import {\n type ResolveNodeForNormalization,\n normalizeStep as coreNormalizeStep,\n normalizeSteps as coreNormalizeSteps,\n} from '@midscene/core/internal/test-runner';\nimport type { NormalizedStep } from './types';\nexport type { ResolveNodeForNormalization } from '@midscene/core/internal/test-runner';\n\nexport const normalizeStep: (\n value: unknown,\n index?: number,\n resolveNode?: ResolveNodeForNormalization,\n) => NormalizedStep = coreNormalizeStep;\nexport const normalizeSteps: (\n values: unknown,\n resolveNode?: ResolveNodeForNormalization,\n) => NormalizedStep[] = coreNormalizeSteps;\n","import type { TestRunReportValue } from '@midscene/core';\nimport {\n isReportSecretKey,\n sanitizeReportText,\n} from '@midscene/core/internal/test-runner';\nimport { JSON_SCHEMA, load } from 'js-yaml';\n\ninterface SourceNode {\n start: number;\n end: number;\n value: unknown;\n children: SourceNode[];\n kind: string | null;\n}\n\n/** Keep author formatting while redacting values by parsed YAML keys, including aliases. */\nexport function parseWorkflowSource(source: string): {\n parsed: unknown;\n sourceYaml: TestRunReportValue;\n locate(\n path: readonly (string | number)[],\n ): { line: number; column: number } | undefined;\n} {\n const stack: SourceNode[] = [];\n const nodes: SourceNode[] = [];\n const sensitiveNodes = new Set<SourceNode>();\n const sensitiveValues = new Set<unknown>();\n const redactedPaths = new Set<string>();\n // js-yaml removes the BOM before reporting source positions.\n const sourceOffset = source.charCodeAt(0) === 0xfeff ? 1 : 0;\n const parsed = load(source, {\n schema: JSON_SCHEMA,\n listener(event, state) {\n if (event === 'open') {\n stack.push({\n start: state.position + sourceOffset,\n end: 0,\n value: null,\n children: [],\n kind: null,\n });\n return;\n }\n const node = stack.pop()!;\n node.end = state.position + sourceOffset;\n node.value = state.result;\n node.kind = state.kind;\n stack.at(-1)?.children.push(node);\n nodes.push(node);\n if (state.kind !== 'mapping') return;\n for (let index = 0; index < node.children.length; index += 2) {\n const key = node.children[index].value;\n const value = node.children[index + 1];\n if (typeof key !== 'string' || !isReportSecretKey(key) || !value)\n continue;\n sensitiveNodes.add(value);\n if (value.value !== null) sensitiveValues.add(value.value);\n redactedPaths.add(`$..[${JSON.stringify(key)}]`);\n }\n },\n });\n // Redact the definition as well when a secret value refers to a YAML anchor.\n const ranges = nodes\n .filter(\n (node) => sensitiveNodes.has(node) || sensitiveValues.has(node.value),\n )\n .sort((left, right) => left.start - right.start || right.end - left.end);\n let offset = 0;\n let redacted = '';\n for (const range of ranges) {\n if (range.start < offset) continue;\n const text = source.slice(range.start, range.end);\n const leading = text.match(/^\\s*/)?.[0] ?? '';\n const trailing = text.slice(leading.length).match(/\\s*$/)?.[0] ?? '';\n redacted += `${source.slice(offset, range.start)}${leading}\"[REDACTED]\"${trailing}`;\n offset = range.end;\n }\n redacted += source.slice(offset);\n const value = sanitizeReportText(redacted, 64 * 1024);\n return {\n parsed,\n locate(path) {\n let node = nodes.at(-1);\n for (const part of path) {\n if (!node) return undefined;\n // js-yaml can emit a wrapper around a block collection.\n while (\n node.children.length === 1 &&\n node.children[0].value === node.value\n )\n node = node.children[0];\n if (typeof part === 'number' && node.kind === 'sequence')\n node = node.children[part];\n else if (typeof part === 'string' && node.kind === 'mapping') {\n const children = node.children;\n node = undefined;\n for (let index = 0; index < children.length; index += 2)\n if (children[index].value === part) {\n node = children[index + 1];\n break;\n }\n } else return undefined;\n }\n if (!node) return undefined;\n let start = node.start;\n while (start < node.end) {\n if (/\\s/.test(source[start])) start++;\n else if (source[start] === '#') {\n const end = source.indexOf('\\n', start);\n if (end < 0) return undefined;\n start = end + 1;\n } else break;\n }\n const prefix = source.slice(0, start).split(/\\r\\n|\\r|\\n/);\n return { line: prefix.length, column: prefix.at(-1)!.length + 1 };\n },\n sourceYaml: {\n value,\n ...(redactedPaths.size ? { redactedPaths: [...redactedPaths] } : {}),\n ...(value !== redacted ? { truncatedPaths: ['$'] } : {}),\n },\n };\n}\n","import type { JsonValue } from '../cli/test-project';\nimport { WorkflowParseError } from '../errors';\n\nexport interface VariableResolutionLocation {\n projectName: string;\n sourcePath: string;\n phase: 'beforeAll' | 'beforeEach' | 'steps' | 'afterEach' | 'afterAll';\n stepIndex: number;\n caseIndex?: number;\n}\n\nexport interface ResolveWorkflowVariablesOptions {\n variables?: Readonly<Record<string, JsonValue>>;\n env?: Readonly<NodeJS.ProcessEnv>;\n location: VariableResolutionLocation;\n}\n\nconst interpolationExpression =\n /\\$\\{\\{([A-Za-z_][A-Za-z0-9_]*)\\}\\}|\\$\\{([^{}]+)\\}/g;\nconst exactEnvExpression = /^\\$\\{\\{([A-Za-z_][A-Za-z0-9_]*)\\}\\}$/;\nconst exactProjectExpression = /^\\$\\{([^{}]+)\\}$/;\n\nconst missingVariable = (\n kind: 'environment' | 'project',\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): never => {\n throw new WorkflowParseError(\n `Undefined ${kind} variable \"${name}\" in ${options.location.sourcePath}.`,\n { ...options.location, variable: name, variableKind: kind },\n );\n};\n\nconst projectVariable = (\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): JsonValue => {\n if (!Object.hasOwn(options.variables ?? {}, name)) {\n return missingVariable('project', name, options);\n }\n return options.variables![name];\n};\n\nconst environmentVariable = (\n name: string,\n options: ResolveWorkflowVariablesOptions,\n): string => {\n const value = options.env?.[name];\n if (value === undefined) return missingVariable('environment', name, options);\n return value;\n};\n\nconst interpolationValue = (\n name: string,\n value: JsonValue,\n options: ResolveWorkflowVariablesOptions,\n): string => {\n if (typeof value === 'object' && value !== null) {\n throw new WorkflowParseError(\n `Project variable \"${name}\" must be a primitive when embedded in a string.`,\n {\n ...options.location,\n variable: name,\n variableKind: 'project',\n },\n );\n }\n return String(value);\n};\n\nconst resolveString = (\n value: string,\n options: ResolveWorkflowVariablesOptions,\n): JsonValue => {\n const exactEnv = exactEnvExpression.exec(value);\n if (exactEnv) return environmentVariable(exactEnv[1], options);\n const exactProject = exactProjectExpression.exec(value);\n if (exactProject) return projectVariable(exactProject[1], options);\n\n return value.replace(\n interpolationExpression,\n (_match, environmentName: string | undefined, projectName: string) =>\n environmentName\n ? environmentVariable(environmentName, options)\n : interpolationValue(\n projectName,\n projectVariable(projectName, options),\n options,\n ),\n );\n};\n\nexport const resolveWorkflowVariables = (\n value: unknown,\n options: ResolveWorkflowVariablesOptions,\n): unknown => {\n if (typeof value === 'string') return resolveString(value, options);\n if (Array.isArray(value)) {\n return value.map((child) => resolveWorkflowVariables(child, options));\n }\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n resolveWorkflowVariables(child, options),\n ]),\n );\n }\n return value;\n};\n","import { readFileSync } from 'node:fs';\nimport { sep } from 'node:path';\nimport { classifyWorkflowDocumentFormat } from '@midscene/core/internal/test-runner';\nimport type { JsonValue } from '../cli/test-project';\nimport { WorkflowParseError } from '../errors';\nimport type { NodeDefinition } from '../node/types';\nimport {\n createCaseInvocationId,\n createDocumentInvocationId,\n} from './identifiers';\nimport { normalizeSteps } from './normalize';\nimport { parseWorkflowSource } from './source';\nimport type {\n CollectedCase,\n CollectedWorkflowDocument,\n WorkflowDocumentSource,\n} from './types';\nimport { resolveWorkflowVariables } from './variables';\n\nexport interface CollectWorkflowDocumentOptions {\n resolveNode(name: string): NodeDefinition<any, any> | undefined;\n variables?: Readonly<Record<string, JsonValue>>;\n env?: Readonly<NodeJS.ProcessEnv>;\n}\n\nconst isMapping = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport class NativeWorkflowFormatError extends WorkflowParseError {\n readonly actualFormat: 'legacy' | 'legacy-batch' | 'mixed';\n\n constructor(\n actualFormat: 'legacy' | 'legacy-batch' | 'mixed',\n sourcePath: string,\n ) {\n super(\n actualFormat === 'legacy'\n ? `Legacy tasks/flow YAML is not supported by midscene-test: ${sourcePath}. Run it with \\`midscene ${sourcePath}\\`, or migrate the file to cases/steps.`\n : actualFormat === 'legacy-batch'\n ? `Legacy YAML batch configuration is not a midscene-test workflow document: ${sourcePath}. Run it with \\`midscene --config ${sourcePath}\\`, or migrate it to a native project config.`\n : `A workflow file cannot mix legacy tasks/flow with native cases/steps or lifecycle hooks: ${sourcePath}. Keep the formats in separate files and run each file with its matching command.`,\n { sourcePath, actualFormat, expectedFormat: 'native' },\n );\n this.actualFormat = actualFormat;\n }\n}\n\nconst rejectUnknownKeys = (\n value: Record<string, unknown>,\n allowed: readonly string[],\n label: string,\n) => {\n const allowedSet = new Set(allowed);\n const unknown = Object.keys(value).filter((key) => !allowedSet.has(key));\n if (unknown.length) {\n throw new WorkflowParseError(\n `${label} has unsupported field \"${unknown[0]}\".`,\n { field: unknown[0] },\n );\n }\n};\n\nexport const createCaseId = (\n projectId: string,\n sourcePath: string,\n caseIndex: number,\n): string => createCaseInvocationId(projectId, sourcePath, caseIndex);\n\nexport const createWorkflowDocumentId = (\n projectId: string,\n sourcePath: string,\n): string => createDocumentInvocationId(projectId, sourcePath);\n\nexport function collectWorkflowDocument(\n source: WorkflowDocumentSource,\n options: CollectWorkflowDocumentOptions,\n): CollectedWorkflowDocument {\n let snapshot: ReturnType<typeof parseWorkflowSource>;\n try {\n snapshot = parseWorkflowSource(readFileSync(source.absolutePath, 'utf8'));\n } catch (error) {\n throw new WorkflowParseError(\n `Failed to parse workflow document \"${source.sourcePath}\".`,\n { sourcePath: source.sourcePath },\n error,\n );\n }\n const { parsed, sourceYaml } = snapshot;\n\n if (!isMapping(parsed)) {\n throw new WorkflowParseError('Workflow document must be a mapping.');\n }\n const format = classifyWorkflowDocumentFormat(parsed);\n if (format === 'legacy' || format === 'legacy-batch' || format === 'mixed') {\n throw new NativeWorkflowFormatError(format, source.sourcePath);\n }\n rejectUnknownKeys(\n parsed,\n ['beforeAll', 'beforeEach', 'cases', 'afterEach', 'afterAll'],\n 'Workflow document',\n );\n if (!Array.isArray(parsed.cases) || parsed.cases.length === 0) {\n throw new WorkflowParseError(\n 'Workflow document must contain a non-empty cases array.',\n );\n }\n\n const sourcePath = source.sourcePath.split(sep).join('/');\n const resolveStepVariables = (\n step: ReturnType<typeof normalizeSteps>[number],\n phase: 'beforeAll' | 'beforeEach' | 'steps' | 'afterEach' | 'afterAll',\n stepIndex: number,\n caseIndex?: number,\n ) => ({\n ...step,\n meta: {\n ...step.meta,\n sourceLocation: snapshot.locate(\n phase === 'steps'\n ? ['cases', caseIndex!, 'steps', stepIndex]\n : [phase, stepIndex],\n ),\n },\n templateInput: step.input,\n input: resolveWorkflowVariables(step.input, {\n variables: options.variables,\n env: options.env ?? process.env,\n location: {\n projectName: source.projectName ?? source.projectId,\n sourcePath,\n phase,\n stepIndex,\n ...(caseIndex === undefined ? {} : { caseIndex }),\n },\n }) as typeof step.input,\n });\n const normalizeLifecycle = (\n phase: 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll',\n ) => {\n const value = parsed[phase];\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new WorkflowParseError(\n `Workflow document ${phase} must be an array.`,\n { phase },\n );\n }\n return normalizeSteps(value, options.resolveNode).map(\n (normalized, stepIndex) => {\n const resolved = options.resolveNode(normalized.node);\n if (!resolved) {\n throw new WorkflowParseError(\n `Workflow document ${phase} step ${stepIndex + 1} references unknown node \"${normalized.node}\".`,\n { phase, stepIndex, node: normalized.node },\n );\n }\n return resolveStepVariables(normalized, phase, stepIndex);\n },\n );\n };\n const lifecycle = {\n beforeAll: normalizeLifecycle('beforeAll'),\n beforeEach: normalizeLifecycle('beforeEach'),\n afterEach: normalizeLifecycle('afterEach'),\n afterAll: normalizeLifecycle('afterAll'),\n };\n const ids = new Set<string>();\n const cases: CollectedCase[] = parsed.cases.map((definition, caseIndex) => {\n if (!isMapping(definition)) {\n throw new WorkflowParseError(`Case ${caseIndex + 1} must be a mapping.`, {\n caseIndex,\n });\n }\n rejectUnknownKeys(\n definition,\n ['name', 'tags', 'steps'],\n `Case ${caseIndex + 1}`,\n );\n if (\n typeof definition.name !== 'string' ||\n definition.name.trim().length === 0\n ) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} name must be a non-empty string.`,\n { caseIndex },\n );\n }\n if (!Array.isArray(definition.steps) || definition.steps.length === 0) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} steps must be a non-empty array.`,\n { caseIndex },\n );\n }\n const tags = definition.tags ?? [];\n if (\n !Array.isArray(tags) ||\n tags.some((tag) => typeof tag !== 'string' || tag.trim().length === 0)\n ) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} tags must be an array of non-empty strings.`,\n { caseIndex },\n );\n }\n\n const steps = normalizeSteps(definition.steps, options.resolveNode).map(\n (normalized, stepIndex) => {\n if (!options.resolveNode(normalized.node)) {\n throw new WorkflowParseError(\n `Case ${caseIndex + 1} step ${stepIndex + 1} references unknown node \"${normalized.node}\".`,\n { caseIndex, stepIndex, node: normalized.node },\n );\n }\n return resolveStepVariables(normalized, 'steps', stepIndex, caseIndex);\n },\n );\n const caseId = createCaseId(source.projectId, sourcePath, caseIndex);\n if (ids.has(caseId)) {\n throw new WorkflowParseError(`Case id collision: ${caseId}.`, {\n caseId,\n });\n }\n ids.add(caseId);\n\n return {\n caseId,\n projectId: source.projectId,\n sourcePath,\n caseIndex,\n definition: {\n name: definition.name,\n tags: tags as string[],\n steps,\n },\n };\n });\n\n return {\n documentId: createWorkflowDocumentId(source.projectId, sourcePath),\n projectId: source.projectId,\n sourcePath,\n sourceYaml,\n lifecycle,\n cases,\n } satisfies CollectedWorkflowDocument;\n}\n","import type { TestRunReportSummary } from '@midscene/core';\n\n/** Use final Case outcomes, not attempts or infrastructure errors. */\nexport function renderTestBadge(\n summary: Pick<TestRunReportSummary, 'passed' | 'failed'>,\n): string {\n return ``;\n}\n","import { writeFile } from 'node:fs/promises';\nimport { dirname, join, relative, sep } from 'node:path';\nimport type {\n TestRunReportDump,\n TestRunReportSourceIndex,\n TestRunReportStep,\n} from '@midscene/core';\nimport type { TestProjectRunResult } from '../cli/types';\nimport { renderTestBadge } from './badge';\nimport { buildTestRunReportDump } from './test-run-report';\n\nconst text = (value: string): string =>\n value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll('|', '|')\n .replaceAll('[', '[')\n .replaceAll(']', ']')\n .replaceAll('*', '*')\n .replaceAll('_', '_')\n .replaceAll('`', '`')\n .replaceAll('\\\\', '\')\n .replace(/[\\r\\n]+/g, ' ');\n\nconst duration = (ms: number): string => {\n const seconds = Math.round(ms / 1000);\n return seconds < 60\n ? `${seconds}s`\n : `${Math.floor(seconds / 60)}m ${seconds % 60}s`;\n};\nconst href = (from: string, target: string): string =>\n relative(dirname(from), target).split(sep).map(encodeURIComponent).join('/');\n\nexport interface TestResultMarkdownOptions {\n /** Relative or hosted URL of the HTML report. */\n reportHref?: string;\n}\n\n/** Render the same sanitized execution facts used by the HTML report. */\nexport function renderTestResultMarkdown(\n dump: TestRunReportDump,\n options: TestResultMarkdownOptions = {},\n): string {\n const { summary } = dump;\n const outcome =\n dump.status === 'success'\n ? `✅ **${summary.passed}/${summary.total} passed**`\n : `❌ **${summary.failed} failed** · ${summary.passed} passed · ${summary.notRun} not run`;\n const lines = [\n '## Midscene Test',\n '',\n renderTestBadge(summary),\n '',\n `${outcome} · ${duration(dump.durationMs)}`,\n '',\n ];\n if (summary.filtered) lines.push(`**Filtered:** ${summary.filtered}`, '');\n const infrastructure = [\n summary.collectionErrors\n ? `${summary.collectionErrors} collection errors`\n : '',\n summary.documentFailures\n ? `${summary.documentFailures} document failures`\n : '',\n summary.projectFailures\n ? `${summary.projectFailures} project failures`\n : '',\n ].filter(Boolean);\n if (infrastructure.length)\n lines.push(`**Infrastructure:** ${infrastructure.join(' · ')}`, '');\n const groups: { name: string; rows: string[] }[] = [];\n const errors: string[] = [];\n const recordSteps = (label: string, steps: readonly TestRunReportStep[]) => {\n for (const step of steps) {\n if (step.status === 'failed')\n errors.push(\n `${label} / ${step.node}: ${step.error?.message ?? 'Step failed'}`,\n );\n }\n };\n for (const project of dump.projects) {\n if (project.lifecycle?.setupError)\n errors.push(`${project.name}: ${project.lifecycle.setupError.message}`);\n for (const error of project.lifecycle?.teardownErrors ?? [])\n errors.push(`${project.name}: ${error.message}`);\n for (const error of project.collectionErrors)\n errors.push(\n `${project.name} / ${error.sourcePath}: ${error.error.message}`,\n );\n for (const document of project.documents) {\n const name = document.sourcePath\n .replace(/\\\\/g, '/')\n .replace(/\\.(?:yaml|yml)$/, '');\n const group = {\n name: dump.projects.length > 1 ? `${project.name} / ${name}` : name,\n rows: [] as string[],\n };\n groups.push(group);\n recordSteps(`${project.name} / ${document.sourcePath}`, [\n ...document.beforeAll,\n ...document.afterAll,\n ]);\n for (const error of document.teardownErrors ?? [])\n errors.push(`${document.sourcePath}: ${error.message}`);\n for (const failure of document.hostErrors ?? [])\n errors.push(\n `${document.sourcePath} / ${failure.phase}: ${failure.error.message}`,\n );\n for (const testCase of document.cases) {\n group.rows.push(\n ` - ${testCase.status === 'success' ? '✅' : testCase.status === 'not-run' ? '⏭️' : '❌'} ${text(testCase.name)}`,\n );\n }\n }\n }\n for (const diagnostic of dump.diagnostics ?? []) {\n if (diagnostic.level === 'error') errors.push(diagnostic.message);\n }\n if (errors.length)\n lines.push(\n '### Execution errors',\n '',\n ...errors.map((error) => `- ${text(error)}`),\n '',\n );\n for (const group of groups) {\n if (group.rows.length) lines.push(`- ${text(group.name)}`, ...group.rows);\n }\n if (!groups.some((group) => group.rows.length))\n lines.push('No cases were reported.');\n if (options.reportHref)\n lines.push(\n '',\n `[Open the Midscene Test report ↗](<${options.reportHref}>)`,\n );\n return `${lines.join('\\n')}\\n`;\n}\n\nconst emptyIndex = (): TestRunReportSourceIndex => ({\n sources: [],\n metrics: {\n modelCallCount: 0,\n modelTimeMs: 0,\n promptTokens: 0,\n cachedInputTokens: 0,\n completionTokens: 0,\n totalTokens: 0,\n },\n});\n\n/** Write a per-run Markdown artifact even when HTML publication fails or is disabled. */\nexport async function writeTestResultMarkdown(\n result: TestProjectRunResult,\n index: TestRunReportSourceIndex = emptyIndex(),\n): Promise<string> {\n const output = join(dirname(result.summaryPath), 'result.md');\n const dump = buildTestRunReportDump(result, index);\n await writeFile(\n output,\n renderTestResultMarkdown(dump, {\n ...(result.reportPath\n ? { reportHref: href(output, result.reportPath) }\n : {}),\n }),\n );\n return output;\n}\n"],"names":["CaseRunner","CoreCaseRunner","createCaseRunner","coreCreateCaseRunner","createDocumentRuntime","coreCreateDocumentRuntime","NodeRegistry","CoreNodeRegistry","runWorkflowDocument","coreRunWorkflowDocument","defineNode","coreDefineNode","createCaseInvocationId","projectId","sourcePath","caseIndex","invocationIndex","createHash","JSON","createDocumentInvocationId","normalizeStep","coreNormalizeStep","normalizeSteps","coreNormalizeSteps","parseWorkflowSource","source","stack","nodes","sensitiveNodes","Set","sensitiveValues","redactedPaths","sourceOffset","parsed","load","JSON_SCHEMA","event","state","node","index","key","value","isReportSecretKey","ranges","left","right","offset","redacted","range","text","leading","trailing","sanitizeReportText","path","part","children","undefined","start","end","prefix","interpolationExpression","exactEnvExpression","exactProjectExpression","missingVariable","kind","name","options","WorkflowParseError","projectVariable","Object","environmentVariable","interpolationValue","String","resolveString","exactEnv","exactProject","_match","environmentName","projectName","resolveWorkflowVariables","Array","child","isMapping","NativeWorkflowFormatError","actualFormat","rejectUnknownKeys","allowed","label","allowedSet","unknown","createCaseId","createWorkflowDocumentId","collectWorkflowDocument","snapshot","readFileSync","error","sourceYaml","format","classifyWorkflowDocumentFormat","sep","resolveStepVariables","step","phase","stepIndex","process","normalizeLifecycle","normalized","resolved","lifecycle","ids","cases","definition","tags","tag","steps","caseId","renderTestBadge","summary","duration","ms","seconds","Math","href","from","target","relative","dirname","encodeURIComponent","renderTestResultMarkdown","dump","outcome","lines","infrastructure","Boolean","groups","errors","recordSteps","project","document","group","failure","testCase","diagnostic","emptyIndex","writeTestResultMarkdown","result","output","join","buildTestRunReportDump","writeFile"],"mappings":";;;;;;;AAmBO,MAAMA,yBAITC;AACG,MAAMC,+BAEeC;ACnBrB,MAAMC,yCAG4BC;ACElC,MAAMC,wBAETC;ACPG,MAAMC,4CAGmCC;ACQzC,MAAMC,yBAA+BC;ACfrC,MAAMC,yBAAyB,CACpCC,WACAC,YACAC,WACAC,kBAAkB,CAAC,GAEnBC,WAAW,UACR,MAAM,CACLC,KAAK,SAAS,CAAC;QACbL;QACAC;QACAC;WACIC,kBAAkB;YAACA;SAAgB,GAAG,EAAE;KAC7C,GAEF,MAAM,CAAC;AAEL,MAAMG,6BAA6B,CACxCN,WACAC,YACAE,kBAAkB,CAAC,GAEnBC,WAAW,UACR,MAAM,CACLC,KAAK,SAAS,CAAC;QACbL;QACAC;WACIE,kBAAkB;YAACA;SAAgB,GAAG,EAAE;KAC7C,GAEF,MAAM,CAAC;ACzBL,MAAMI,0BAISC;AACf,MAAMC,2BAGWC;ACAjB,SAASC,oBAAoBC,MAAc;IAOhD,MAAMC,QAAsB,EAAE;IAC9B,MAAMC,QAAsB,EAAE;IAC9B,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,kBAAkB,IAAID;IAC5B,MAAME,gBAAgB,IAAIF;IAE1B,MAAMG,eAA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CAC7C,IAAIa,AAAqB,YAArBA,WAAW,KAAK,EAAcP,OAAO,IAAI,CAACO,WAAW,OAAO;IAElE,IAAIP,OAAO,MAAM,EACfJ,MAAM,IAAI,CACR,wBACA,OACGI,OAAO,GAAG,CAAC,CAACxC,QAAU,CAAC,EAAE,EAAE9C,qBAAK8C,QAAQ,GAC3C;IAEJ,KAAK,MAAM4C,SAASL,OAClB,IAAIK,MAAM,IAAI,CAAC,MAAM,EAAER,MAAM,IAAI,CAAC,CAAC,EAAE,EAAElF,qBAAK0F,MAAM,IAAI,GAAG,KAAKA,MAAM,IAAI;IAE1E,IAAI,CAACL,OAAO,IAAI,CAAC,CAACK,QAAUA,MAAM,IAAI,CAAC,MAAM,GAC3CR,MAAM,IAAI,CAAC;IACb,IAAIjE,QAAQ,UAAU,EACpBiE,MAAM,IAAI,CACR,IACA,CAAC,mCAAmC,EAAEjE,QAAQ,UAAU,CAAC,EAAE,CAAC;IAEhE,OAAO,GAAGiE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;AAChC;AAEA,MAAMY,aAAa,IAAiC;QAClD,SAAS,EAAE;QACX,SAAS;YACP,gBAAgB;YAChB,aAAa;YACb,cAAc;YACd,mBAAmB;YACnB,kBAAkB;YAClB,aAAa;QACf;IACF;AAGO,eAAeC,wBACpBC,MAA4B,EAC5B1G,QAAkCwG,YAAY;IAE9C,MAAMG,SAASC,KAAKrB,QAAQmB,OAAO,WAAW,GAAG;IACjD,MAAMhB,OAAOmB,uBAAuBH,QAAQ1G;IAC5C,MAAM8G,UACJH,QACAlB,yBAAyBC,MAAM;QAC7B,GAAIgB,OAAO,UAAU,GACjB;YAAE,YAAYvB,KAAKwB,QAAQD,OAAO,UAAU;QAAE,IAC9C,CAAC,CAAC;IACR;IAEF,OAAOC;AACT"}
|
package/dist/es/test-cli.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { globSync } from "tinyglobby";
|
|
|
13
13
|
import { createHash, randomUUID } from "node:crypto";
|
|
14
14
|
import { JSON_SCHEMA, load } from "js-yaml";
|
|
15
15
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
16
|
+
import { resolveMidsceneRunDir, runWithMidsceneRunDir } from "@midscene/shared/common";
|
|
16
17
|
import { setMaxListeners } from "node:events";
|
|
17
18
|
import { ReportSession, TestRunReportAssembler, calculateTestRunHealth } from "@midscene/core/report";
|
|
18
19
|
var __webpack_modules__ = {
|
|
@@ -30,7 +31,7 @@ var __webpack_modules__ = {
|
|
|
30
31
|
},
|
|
31
32
|
"./package.json" (module) {
|
|
32
33
|
module.exports = {
|
|
33
|
-
rE: "1.17.
|
|
34
|
+
rE: "1.17.7"
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
};
|
|
@@ -105,6 +106,9 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
105
106
|
})();
|
|
106
107
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
107
108
|
var external_node_path_ = __webpack_require__("node:path");
|
|
109
|
+
function renderTestBadge(summary) {
|
|
110
|
+
return ``;
|
|
111
|
+
}
|
|
108
112
|
var external_chalk_ = __webpack_require__("chalk");
|
|
109
113
|
var package_0 = __webpack_require__("./package.json");
|
|
110
114
|
const formatCliError = (error)=>'string' == typeof error ? error : inspect(error, {
|
|
@@ -1097,6 +1101,8 @@ function writeGitHubSummary(result) {
|
|
|
1097
1101
|
const summary = [
|
|
1098
1102
|
'## Midscene Test',
|
|
1099
1103
|
'',
|
|
1104
|
+
renderTestBadge(result.summary),
|
|
1105
|
+
'',
|
|
1100
1106
|
'| Passed | Failed | Not run | Passed after retry | Duration |',
|
|
1101
1107
|
'| ---: | ---: | ---: | ---: | ---: |',
|
|
1102
1108
|
`| ${result.summary.passed} | ${result.summary.failed} | ${result.summary.notRun} | ${result.summary.passedAfterRetry} | ${formatDuration(result.durationMs)} |`,
|
|
@@ -1514,8 +1520,7 @@ const validateTestOptions = (value, hasExplicitProjects)=>{
|
|
|
1514
1520
|
testTimeout: validatePositiveInteger(candidate.testTimeout, 120000, 'test.testTimeout')
|
|
1515
1521
|
});
|
|
1516
1522
|
};
|
|
1517
|
-
const validateOutputPath = (value,
|
|
1518
|
-
if (void 0 === value) return fallback;
|
|
1523
|
+
const validateOutputPath = (value, label)=>{
|
|
1519
1524
|
if ('string' != typeof value || 0 === value.trim().length) throw new TypeError(`Midscene config ${label} must be non-empty.`);
|
|
1520
1525
|
return value;
|
|
1521
1526
|
};
|
|
@@ -1529,7 +1534,9 @@ const validateOutput = (value)=>{
|
|
|
1529
1534
|
if (void 0 !== candidate.reportFormat && 'single-html' !== candidate.reportFormat && 'html-and-external-assets' !== candidate.reportFormat) throw new TypeError('Midscene config output.reportFormat must be single-html or html-and-external-assets.');
|
|
1530
1535
|
return Object.freeze({
|
|
1531
1536
|
reportFormat: candidate.reportFormat ?? 'single-html',
|
|
1532
|
-
|
|
1537
|
+
...void 0 === candidate.reportDir ? {} : {
|
|
1538
|
+
reportDir: validateOutputPath(candidate.reportDir, 'output.reportDir')
|
|
1539
|
+
}
|
|
1533
1540
|
});
|
|
1534
1541
|
};
|
|
1535
1542
|
const validateTestProjectDefinition = (definition)=>{
|
|
@@ -2117,8 +2124,16 @@ const DEFAULT_TEST_FILE_SELECTION = {
|
|
|
2117
2124
|
]
|
|
2118
2125
|
};
|
|
2119
2126
|
const project_preparation_toPosix = (value)=>value.split(external_node_path_.sep).join('/');
|
|
2120
|
-
const discoverResolvedTestFiles = (projectRoot, selection)=>{
|
|
2127
|
+
const discoverResolvedTestFiles = (projectRoot, selection, excludedDirectories = [])=>{
|
|
2121
2128
|
const root = (0, external_node_path_.resolve)(projectRoot);
|
|
2129
|
+
const outputPatterns = excludedDirectories.flatMap((directory)=>{
|
|
2130
|
+
const withinRoot = (0, external_node_path_.relative)(root, directory);
|
|
2131
|
+
if (!withinRoot || (0, external_node_path_.isAbsolute)(withinRoot) || '..' === withinRoot || withinRoot.startsWith(`..${external_node_path_.sep}`)) return [];
|
|
2132
|
+
const literal = project_preparation_toPosix(withinRoot).replace(/([*?{}[\]()!])/g, '\\$1');
|
|
2133
|
+
return [
|
|
2134
|
+
`${literal}/**`
|
|
2135
|
+
];
|
|
2136
|
+
});
|
|
2122
2137
|
const match = (patterns)=>globSync(patterns, {
|
|
2123
2138
|
absolute: true,
|
|
2124
2139
|
caseSensitiveMatch: false,
|
|
@@ -2128,6 +2143,7 @@ const discoverResolvedTestFiles = (projectRoot, selection)=>{
|
|
|
2128
2143
|
followSymbolicLinks: false,
|
|
2129
2144
|
ignore: [
|
|
2130
2145
|
...ALWAYS_IGNORED_PATTERNS,
|
|
2146
|
+
...outputPatterns,
|
|
2131
2147
|
...selection.exclude ?? []
|
|
2132
2148
|
],
|
|
2133
2149
|
onlyFiles: true
|
|
@@ -2197,7 +2213,7 @@ async function prepareProject(project, projectRoot, runDir, defaultTimeoutMs, op
|
|
|
2197
2213
|
const platform = options.platform?.trim();
|
|
2198
2214
|
const fileSelection = project.files ?? DEFAULT_TEST_FILE_SELECTION;
|
|
2199
2215
|
const prerequisiteFile = options.prerequisiteFile ? (0, external_node_path_.resolve)(options.prerequisiteFile) : void 0;
|
|
2200
|
-
const mainFiles = options.files ?? discoverResolvedTestFiles(projectRoot, fileSelection);
|
|
2216
|
+
const mainFiles = options.files ?? discoverResolvedTestFiles(projectRoot, fileSelection, options.excludedDirectories);
|
|
2201
2217
|
const files = [
|
|
2202
2218
|
...prerequisiteFile ? [
|
|
2203
2219
|
prerequisiteFile
|
|
@@ -2362,40 +2378,58 @@ async function prepareTestRun(options) {
|
|
|
2362
2378
|
if (options.configPath && /\.ya?ml$/i.test(configPath)) throw new Error(`midscene-test --config only accepts a native TypeScript or JavaScript project config: ${configPath}. Run legacy batch YAML with \`midscene --config ${options.configPath}\`.`);
|
|
2363
2379
|
if (options.configPath && !(0, external_node_fs_.existsSync)(configPath)) throw new Error(`Midscene config does not exist: ${configPath}`);
|
|
2364
2380
|
const definition = await loadTestProject(configPath);
|
|
2365
|
-
const
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2381
|
+
const artifactDir = resolveMidsceneRunDir(input.projectRoot);
|
|
2382
|
+
return runWithMidsceneRunDir(artifactDir, async ()=>{
|
|
2383
|
+
const resultDir = options.resultDir ? (0, external_node_path_.resolve)(input.cwd, options.resultDir) : (0, external_node_path_.join)(artifactDir, 'test-results');
|
|
2384
|
+
const runDir = (0, external_node_path_.join)(resultDir, runId);
|
|
2385
|
+
const summaryPath = (0, external_node_path_.join)(runDir, 'summary.json');
|
|
2386
|
+
const reportDir = definition.output.reportDir ? (0, external_node_path_.resolve)(input.projectRoot, definition.output.reportDir) : (0, external_node_path_.join)(artifactDir, 'report');
|
|
2387
|
+
(0, external_node_fs_.mkdirSync)(resultDir, {
|
|
2388
|
+
recursive: true
|
|
2389
|
+
});
|
|
2390
|
+
(0, external_node_fs_.mkdirSync)(runDir);
|
|
2391
|
+
const projects = [];
|
|
2392
|
+
for (const project of selectProjects(definition.projects, options.projectNames))projects.push(await prepareProject(project, input.projectRoot, runDir, definition.test.testTimeout, {
|
|
2393
|
+
...input.singleFile ? {
|
|
2394
|
+
files: [
|
|
2395
|
+
input.singleFile
|
|
2396
|
+
]
|
|
2397
|
+
} : {},
|
|
2398
|
+
excludedDirectories: [
|
|
2399
|
+
artifactDir,
|
|
2400
|
+
resultDir,
|
|
2401
|
+
reportDir,
|
|
2402
|
+
...[
|
|
2403
|
+
'cache',
|
|
2404
|
+
'log',
|
|
2405
|
+
'output',
|
|
2406
|
+
'tmp',
|
|
2407
|
+
'dump'
|
|
2408
|
+
].map((name)=>(0, external_node_path_.join)(artifactDir, name))
|
|
2409
|
+
]
|
|
2410
|
+
}));
|
|
2411
|
+
const hasFormatMismatch = projects.some((project)=>project.collectionErrors.some(({ error })=>error instanceof NativeWorkflowFormatError));
|
|
2412
|
+
return {
|
|
2413
|
+
startedAt,
|
|
2414
|
+
runId,
|
|
2415
|
+
projectRoot: input.projectRoot,
|
|
2416
|
+
artifactDir,
|
|
2417
|
+
...configPath ? {
|
|
2418
|
+
configPath
|
|
2419
|
+
} : {},
|
|
2420
|
+
resultDir,
|
|
2421
|
+
runDir,
|
|
2422
|
+
summaryPath,
|
|
2423
|
+
reportDir,
|
|
2424
|
+
definition,
|
|
2425
|
+
projects,
|
|
2426
|
+
preflightScope: hasFormatMismatch ? 'run' : 'project',
|
|
2427
|
+
reportEnabled: true,
|
|
2428
|
+
publications: [],
|
|
2429
|
+
onProgress: options.onProgress ?? (()=>{}),
|
|
2430
|
+
onEvent: options.onEvent
|
|
2431
|
+
};
|
|
2371
2432
|
});
|
|
2372
|
-
(0, external_node_fs_.mkdirSync)(runDir);
|
|
2373
|
-
const projects = [];
|
|
2374
|
-
for (const project of selectProjects(definition.projects, options.projectNames))projects.push(await prepareProject(project, input.projectRoot, runDir, definition.test.testTimeout, input.singleFile ? {
|
|
2375
|
-
files: [
|
|
2376
|
-
input.singleFile
|
|
2377
|
-
]
|
|
2378
|
-
} : void 0));
|
|
2379
|
-
const hasFormatMismatch = projects.some((project)=>project.collectionErrors.some(({ error })=>error instanceof NativeWorkflowFormatError));
|
|
2380
|
-
return {
|
|
2381
|
-
startedAt,
|
|
2382
|
-
runId,
|
|
2383
|
-
projectRoot: input.projectRoot,
|
|
2384
|
-
...configPath ? {
|
|
2385
|
-
configPath
|
|
2386
|
-
} : {},
|
|
2387
|
-
resultDir,
|
|
2388
|
-
runDir,
|
|
2389
|
-
summaryPath,
|
|
2390
|
-
reportDir,
|
|
2391
|
-
definition,
|
|
2392
|
-
projects,
|
|
2393
|
-
preflightScope: hasFormatMismatch ? 'run' : 'project',
|
|
2394
|
-
reportEnabled: true,
|
|
2395
|
-
publications: [],
|
|
2396
|
-
onProgress: options.onProgress ?? (()=>{}),
|
|
2397
|
-
onEvent: options.onEvent
|
|
2398
|
-
};
|
|
2399
2433
|
}
|
|
2400
2434
|
const result_markdown_text = (value)=>value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll('|', '|').replaceAll('[', '[').replaceAll(']', ']').replaceAll('*', '*').replaceAll('_', '_').replaceAll('`', '`').replaceAll('\\', '\').replace(/[\r\n]+/g, ' ');
|
|
2401
2435
|
const result_markdown_duration = (ms)=>{
|
|
@@ -2409,6 +2443,8 @@ function renderTestResultMarkdown(dump, options = {}) {
|
|
|
2409
2443
|
const lines = [
|
|
2410
2444
|
'## Midscene Test',
|
|
2411
2445
|
'',
|
|
2446
|
+
renderTestBadge(summary),
|
|
2447
|
+
'',
|
|
2412
2448
|
`${outcome} · ${result_markdown_duration(dump.durationMs)}`,
|
|
2413
2449
|
''
|
|
2414
2450
|
];
|
|
@@ -3111,7 +3147,7 @@ const latestById = (items, id)=>[
|
|
|
3111
3147
|
const notRunSuite = (prepared, reason)=>prepared.documents.flatMap((document)=>document.cases.map((item)=>asNotRun(document.documentId, item, prepared.project.name, reason)));
|
|
3112
3148
|
async function runPreparedTestProject(plan) {
|
|
3113
3149
|
const reports = new ReportSession((0, external_node_path_.join)(plan.runDir, 'records'));
|
|
3114
|
-
return reports.run(()=>runWithReportSession(plan, reports));
|
|
3150
|
+
return runWithMidsceneRunDir(plan.artifactDir, ()=>reports.run(()=>runWithReportSession(plan, reports)));
|
|
3115
3151
|
}
|
|
3116
3152
|
async function runWithReportSession(plan, reports) {
|
|
3117
3153
|
const { startedAt, runId, projectRoot, configPath, resultDir, runDir, summaryPath, reportDir, definition, projects: preparedProjects } = plan;
|