diff options
Diffstat (limited to 'integration-tests/test-helper.js')
| -rw-r--r-- | integration-tests/test-helper.js | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/integration-tests/test-helper.js b/integration-tests/test-helper.js index eb598bd9..7acdc7aa 100644 --- a/integration-tests/test-helper.js +++ b/integration-tests/test-helper.js @@ -47,14 +47,30 @@ export class TestRig { execSync('sync', { cwd: this.testDir }); } - run(prompt, ...args) { - const output = execSync( - `node ${this.bundlePath} --yolo --prompt "${prompt}" ${args.join(' ')}`, - { - cwd: this.testDir, - encoding: 'utf-8', - }, - ); + run(promptOrOptions, ...args) { + let command = `node ${this.bundlePath} --yolo`; + const execOptions = { + cwd: this.testDir, + encoding: 'utf-8', + }; + + if (typeof promptOrOptions === 'string') { + command += ` --prompt "${promptOrOptions}"`; + } else if ( + typeof promptOrOptions === 'object' && + promptOrOptions !== null + ) { + if (promptOrOptions.prompt) { + command += ` --prompt "${promptOrOptions.prompt}"`; + } + if (promptOrOptions.stdin) { + execOptions.input = promptOrOptions.stdin; + } + } + + command += ` ${args.join(' ')}`; + + const output = execSync(command, execOptions); if (env.KEEP_OUTPUT === 'true') { const testId = `${env.TEST_FILE_NAME.replace( |
