{"id":21078781,"url":"https://github.com/timokoessler/interactive-cli-tester","last_synced_at":"2026-04-09T20:49:49.895Z","repository":{"id":219609791,"uuid":"749420184","full_name":"timokoessler/interactive-cli-tester","owner":"timokoessler","description":"A tool for testing interactive command line interfaces","archived":false,"fork":false,"pushed_at":"2024-03-12T18:10:20.000Z","size":463,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T23:08:03.904Z","etag":null,"topics":["cli","command-line","command-line-interface","jest","terminal","test","testing"],"latest_commit_sha":null,"homepage":"https://cli-tester.tkoessler.de","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timokoessler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-28T14:37:46.000Z","updated_at":"2024-11-01T15:03:50.000Z","dependencies_parsed_at":"2024-02-11T11:23:36.410Z","dependency_job_id":"8f20a935-a1e4-4988-8c0d-dde90b9093cb","html_url":"https://github.com/timokoessler/interactive-cli-tester","commit_stats":null,"previous_names":["timokoessler/interactive-cli-tester"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timokoessler%2Finteractive-cli-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timokoessler%2Finteractive-cli-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timokoessler%2Finteractive-cli-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timokoessler%2Finteractive-cli-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timokoessler","download_url":"https://codeload.github.com/timokoessler/interactive-cli-tester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521210,"owners_count":20304188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","command-line-interface","jest","terminal","test","testing"],"created_at":"2024-11-19T19:42:18.544Z","updated_at":"2025-12-28T20:54:24.148Z","avatar_url":"https://github.com/timokoessler.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Interactive CLI Tester\n\n[![npm version](https://badgen.net/npm/v/interactive-cli-tester)](https://www.npmjs.com/package/interactive-cli-tester)\n[![npm downloads](https://badgen.net/npm/dt/interactive-cli-tester)](https://www.npmjs.com/package/interactive-cli-tester)\n[![license](https://badgen.net/github/license/timokoessler/interactive-cli-tester)](https://github.com/timokoessler/interactive-cli-tester/blob/main/LICENSE)\n[![CodeFactor](https://www.codefactor.io/repository/github/timokoessler/interactive-cli-tester/badge)](https://www.codefactor.io/repository/github/timokoessler/interactive-cli-tester)\n[![codecov](https://codecov.io/gh/timokoessler/interactive-cli-tester/graph/badge.svg?token=N3E9VX3ELT)](https://codecov.io/gh/timokoessler/interactive-cli-tester)\n[![install size](https://packagephobia.com/badge?p=interactive-cli-tester)](https://packagephobia.com/result?p=interactive-cli-tester)\n\nA tool for testing interactive command line interfaces that require keyboard input.\n\n\u003e ⚠️ This software is still in development and not ready for production use.\n\nYou can find a complete API documentation [here](https://cli-tester.tkoessler.de).\n\n## Features\n\n-   Test every command line interface - no matter in which programming language it is written 🧪\n-   Test interactive command line interfaces that require user input ⌨️\n-   Independent of the testing framework you want to use 😎\n-   Zero dependencies 📦\n\n## Getting Started\n\nYou can install this package using npm:\n\n```bash\nnpm install --save-dev interactive-cli-tester\n```\n\nThe following example shows how to test a simple interactive CLI build with [enquirer](https://github.com/enquirer/enquirer) using [Jest](https://jestjs.io/). But you can use any Node.js testing framework you want.\n\n```javascript\nimport { CLITest, ANSI } from 'interactive-cli-tester';\n\ntest('Test example CLI', async () =\u003e {\n    const cliTest = new CLITest('node', ['examples/readme.mjs']);\n\n    // Start the process, you can re-use the same instance for multiple runs\n    await cliTest.run();\n\n    // Wait until the CLI asks for input\n    await cliTest.waitForOutput('What do you want to do?');\n    // Equivalent to pressing down arrow and enter\n    await cliTest.write(ANSI.CURSOR_DOWN + ANSI.CR);\n\n    // Expect the CLI to ask for the name\n    await cliTest.waitForOutput('Input your name');\n    await cliTest.write('Acme' + ANSI.CR);\n\n    // Wait for the process to exit and check the exit code\n    expect(await cliTest.waitForExit()).toBe(0);\n\n    // Check that the output contains the expected text\n    expect(cliTest.getOutput().includes('Hello Acme!')).toBe(true);\n});\n```\n\nA complete API documentation including all available methods and options can be found [here](https://cli-tester.tkoessler.de).\n\n## Code Coverage\n\nIt can be difficult to configure your testing framework to collect code coverage for Node.js child processes. For example, Jest does not support this out of the box ([#5274](https://github.com/jestjs/jest/issues/5274)), even though [bcoe/c8](https://github.com/bcoe/c8) and [istanbuljs/nyc](https://github.com/istanbuljs/nyc) do. One possible workaround for Jest is described in [this comment](https://github.com/jestjs/jest/issues/3190#issuecomment-354758036), but this is not a perfect solution and may not work when using TypeScript.\n\nYou can find a complicated and not perfect workaround using two seperate Jest runners and nyc in my repo [timokoessler/docker-deploy-api](https://github.com/timokoessler/docker-deploy-api). I am not using c8 because of the issue [#462](https://github.com/bcoe/c8/issues/462).\n\nIf you have a question, have found a better way or successfully used another testing framework, please create an issue or send me a message.\n\n## Sources\n\n-   [ANSI Escape Sequences](https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797)\n\n## Contact\n\nIf a public GitHub issue or discussion is not the right choice for your concern, you can contact me directly:\n\n-   E-Mail: [info@timokoessler.de](mailto:info@timokoessler.de)\n\n## License\n\n© [Timo Kössler](https://timokoessler.de) 2024  \nReleased under the [MIT license](https://github.com/timokoessler/interactive-cli-tester/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimokoessler%2Finteractive-cli-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimokoessler%2Finteractive-cli-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimokoessler%2Finteractive-cli-tester/lists"}