{"id":13485013,"url":"https://github.com/vadimdemedes/ink-testing-library","last_synced_at":"2025-05-13T00:58:40.777Z","repository":{"id":57274080,"uuid":"174081010","full_name":"vadimdemedes/ink-testing-library","owner":"vadimdemedes","description":"Utilities for testing Ink apps","archived":false,"fork":false,"pushed_at":"2024-06-28T23:54:38.000Z","size":20,"stargazers_count":116,"open_issues_count":8,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T12:33:27.756Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/vadimdemedes.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"vadimdemedes","custom":"https://www.comebackalive.in.ua"}},"created_at":"2019-03-06T05:56:00.000Z","updated_at":"2025-04-22T17:44:17.000Z","dependencies_parsed_at":"2022-09-17T10:12:53.683Z","dependency_job_id":"99aff580-c2e6-4396-a130-3753880d217d","html_url":"https://github.com/vadimdemedes/ink-testing-library","commit_stats":{"total_commits":28,"total_committers":8,"mean_commits":3.5,"dds":0.5,"last_synced_commit":"1673165d94905066f13b1bc6e1f9eacef8f3688e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink-testing-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink-testing-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink-testing-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink-testing-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vadimdemedes","download_url":"https://codeload.github.com/vadimdemedes/ink-testing-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253641587,"owners_count":21940740,"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":[],"created_at":"2024-07-31T17:01:42.636Z","updated_at":"2025-05-13T00:58:40.754Z","avatar_url":"https://github.com/vadimdemedes.png","language":"TypeScript","funding_links":["https://opencollective.com/vadimdemedes","https://www.comebackalive.in.ua"],"categories":["TypeScript","JavaScript"],"sub_categories":[],"readme":"# ink-testing-library ![test](https://github.com/vadimdemedes/ink-testing-library/workflows/test/badge.svg)\n\n\u003e Utilities for testing [Ink](https://github.com/vadimdemedes/ink) apps\n\n## Install\n\n```\n$ npm install --save-dev ink-testing-library\n```\n\n## Usage\n\n```jsx\nimport React from 'react';\nimport {Text} from 'ink';\nimport {render} from 'ink-testing-library';\n\nconst Counter = ({count}) =\u003e \u003cText\u003eCount: {count}\u003c/Text\u003e;\n\nconst {lastFrame, rerender} = render(\u003cCounter count={0}/\u003e);\nlastFrame() === 'Count: 0'; //=\u003e true\n\nrerender(\u003cCounter count={1}/\u003e);\nlastFrame() === 'Count: 1'; //=\u003e true\n```\n\n## API\n\n### render(tree)\n\n#### tree\n\nType: `ReactElement`\n\nReact component to render.\n\n```jsx\nrender(\u003cMyApp/\u003e);\n```\n\nThis function returns an object, which contains the following methods and properties.\n\n#### lastFrame()\n\nType: `function`\n\nShortcut to [`stdout.lastFrame`](#lastframe-1).\n\n#### frames\n\nType: `array`\n\nShortcut to [`stdout.frames`](#frames-1).\n\n#### rerender(tree)\n\nType: `function`\n\n##### tree\n\nType: `ReactElement`\n\nRerender root component with different props or replace with another component.\n\n```jsx\nconst {rerender} = render(\u003cOldApp/\u003e);\nrerender(\u003cNewApp/\u003e);\n```\n\n#### unmount()\n\nType: `function`\n\nUnmount current component.\n\n```jsx\nconst {unmount} = render(\u003cTest/\u003e);\nunmount();\n```\n\n#### stdin\n\nType: `object`\n\n##### write()\n\nType: `function`\n\nWrite data to current component's stdin stream.\n\n```jsx\nimport {useInput, Text} from 'ink';\n\nconst Test = () =\u003e {\n\tuseInput(input =\u003e {\n\t\tconsole.log(input);\n\t\t//=\u003e 'hello'\n\t});\n\n\treturn …;\n};\n\nconst {stdin} = render(\u003cTest/\u003e);\nstdin.write('hello');\n```\n\n#### stdout\n\nType: `object`\n\n##### lastFrame()\n\nType: `function`\n\nReturn the last rendered frame (output) from stdout stream.\n\n```jsx\nconst Test = () =\u003e \u003cText\u003eHello\u003c/Text\u003e;\n\nconst {stdout} = render(\u003cTest/\u003e);\nstdout.lastFrame(); //=\u003e 'Hello'\n```\n\n##### frames\n\nType: `array`\n\nArray of all rendered frames, where the last frame is also the last item in that array.\n\n```jsx\nconst Counter = ({count}) =\u003e \u003cText\u003eCount: {count}\u003c/Text\u003e;\n\nconst {stdout, rerender} = render(\u003cCounter count={0}/\u003e);\nrerender(\u003cCounter count={1}/\u003e);\n\nconsole.log(stdout.frames); //=\u003e ['Count: 0', 'Count: 1']\n```\n\n#### stderr\n\nType: `object`\n\n##### lastFrame()\n\nType: `function`\n\nSame as [`lastFrame`](#lastframe-1) in [`stdout`](#stdout), but for stderr stream.\n\n##### frames\n\nType: `array`\n\nSame as [`frames`](#frames-1) in [`stdout`](#stdout), but for stderr stream.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimdemedes%2Fink-testing-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadimdemedes%2Fink-testing-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimdemedes%2Fink-testing-library/lists"}