{"id":16003583,"url":"https://github.com/nhatthm/surveysteps","last_synced_at":"2026-01-28T18:32:33.776Z","repository":{"id":59045285,"uuid":"530191972","full_name":"nhatthm/surveysteps","owner":"nhatthm","description":"Survey steps for cucumber/godog","archived":false,"fork":false,"pushed_at":"2024-11-25T18:46:09.000Z","size":221,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T01:41:24.848Z","etag":null,"topics":["bdd","console","cucumber","functional-testing","gherkin","go","godog","godog-extension","golang","integration-testing","prompt","survey","surveymock","testing"],"latest_commit_sha":null,"homepage":"https://go.nhat.io/surveysteps","language":"Go","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/nhatthm.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}},"created_at":"2022-08-29T11:37:04.000Z","updated_at":"2024-07-06T21:10:00.000Z","dependencies_parsed_at":"2024-01-22T12:14:58.781Z","dependency_job_id":"1fd34355-8d8c-4018-bda0-b4bace331d14","html_url":"https://github.com/nhatthm/surveysteps","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nhatthm/surveysteps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthm%2Fsurveysteps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthm%2Fsurveysteps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthm%2Fsurveysteps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthm%2Fsurveysteps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhatthm","download_url":"https://codeload.github.com/nhatthm/surveysteps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthm%2Fsurveysteps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28849160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bdd","console","cucumber","functional-testing","gherkin","go","godog","godog-extension","golang","integration-testing","prompt","survey","surveymock","testing"],"created_at":"2024-10-08T10:21:23.921Z","updated_at":"2026-01-28T18:32:33.760Z","avatar_url":"https://github.com/nhatthm.png","language":"Go","funding_links":["https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY"],"categories":[],"sub_categories":[],"readme":"# Cucumber Survey steps for Go\n\n[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/surveysteps)](https://github.com/nhatthm/surveysteps/releases/latest)\n[![Build Status](https://github.com/nhatthm/surveysteps/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/surveysteps/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/nhatthm/surveysteps/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/surveysteps)\n[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/surveysteps)](https://goreportcard.com/report/go.nhat.io/surveysteps)\n[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/surveysteps)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)\n\nTests with `AlecAivazis/survey` and `cucumber/godog`\n\n## Prerequisites\n\n- `Go \u003e= 1.17`\n\n## Install\n\n```bash\ngo get go.nhat.io/surveysteps\n```\n\n## Usage\n\n### Supported Types\n\n| Type          | Supported | Supported Actions                                                                                          |\n|:--------------|:---------:|:-----------------------------------------------------------------------------------------------------------|\n| `Confirm`     |     ✓     | \u003cul\u003e\u003cli\u003eAnswer `yes`, `no` or a custom one\u003c/li\u003e\u003cli\u003eInterrupt (`^C`)\u003c/li\u003e\u003cli\u003eAsk for help\u003c/li\u003e\u003c/ul\u003e         |\n| `Editor`      |     ✘     |                                                                                                            |\n| `Input`       |     ✘     |                                                                                                            |\n| `Multiline`   |     ✓     | \u003cul\u003e\u003cli\u003eAnswer\u003c/li\u003e\u003cli\u003eNo answer\u003c/li\u003e\u003cli\u003eInterrupt (`^C`)\u003c/li\u003e\u003c/ul\u003e                                        |\n| `Multiselect` |     ✘     |                                                                                                            |\n| `Password`    |     ✓     | \u003cul\u003e\u003cli\u003eAnswer (+ check for `*`)\u003c/li\u003e\u003cli\u003eNo answer\u003c/li\u003e\u003cli\u003eInterrupt (`^C`)\u003c/li\u003e\u003cli\u003eAsk for help\u003c/li\u003e\u003c/ul\u003e |\n| `Select`      |     ✘     |                                                                                                            |\n\n## Setup\n\nStep 1: Register to `godog`\n\nInitialize a `surveysteps.Manager` with `surveysteps.New()` then add it into the `ScenarioInitializer`\n\nStep 2: Pass `stdio` to the prompts\n\nSame as [`surveyexpect`](https://github.com/nhatthm/surveyexpect#expect), you have to define a way to inject `terminal.Stdio` into the prompts in your code. For\nevery scenario, the manager will start a new terminal emulator. Without the injection, there is no way to capture and response to the prompts.\n\nYou can register to the `Start` event and use the provided `terminal.Stdio` accordingly.\n\nFor example:\n\n```go\npackage mypackage\n\nimport (\n\t\"math/rand\"\n\t\"testing\"\n\n\tsurvey \"github.com/AlecAivazis/survey/v2\"\n\t\"github.com/AlecAivazis/survey/v2/terminal\"\n\t\"github.com/cucumber/godog\"\n\t\"go.nhat.io/surveyexpect/options\"\n\t\"go.nhat.io/surveysteps\"\n)\n\ntype Wizard struct {\n\tstdio terminal.Stdio\n}\n\nfunc (w *Wizard) start(_ *godog.Scenario, stdio terminal.Stdio) {\n\tw.stdio = stdio\n}\n\nfunc (w *Wizard) ask() (bool, error) {\n\tvar response bool\n\n\tp := \u0026survey.Confirm{Message: \"Confirm?\"}\n\terr := survey.AskOne(p, \u0026response, options.WithStdio(w.stdio))\n\n\treturn response, err\n}\n\nfunc TestIntegration(t *testing.T) {\n\twizard := \u0026Wizard{}\n\tm := surveysteps.New(t).\n\t\tWithStarter(wizard.start)\n\n\tsuite := godog.TestSuite{\n\t\tName: \"Integration\",\n\t\tScenarioInitializer: func(ctx *godog.ScenarioContext) {\n\t\t\tm.RegisterContext(ctx)\n\t\t},\n\t\tOptions: \u0026godog.Options{\n\t\t\tStrict:    true,\n\t\t\tOutput:    out,\n\t\t\tRandomize: rand.Int63(),\n\t\t},\n\t}\n\n\t// Run the suite that triggers wizard.ask()\n}\n```\n\nSee more: [#Examples](#Examples)\n\n## Steps\n\n### Confirm\n\n#### Yes\n\nExpect to see a Confirm prompt and answer `yes`.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? confirm prompt \"([^\"]*)\".* answers? yes`\n\nExample:\n\n```gherkin\n    Scenario: Receive a yes\n        Given I see a confirm prompt \"Confirm? (y/N)\", I answer yes\n\n        Then ask for confirm \"Confirm?\", receive yes\n```\n\n#### No\n\nExpect to see a Confirm prompt and answer `no`.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? confirm prompt \"([^\"]*)\".* answers? no`\n\nExample:\n\n```gherkin\n    Scenario: Receive a no\n        Given I see a confirm prompt \"Confirm? (y/N)\", I answer no\n\n        Then ask for confirm \"Confirm?\", receive no\n```\n\n#### Invalid answer\n\nExpect to see a Confirm prompt and answer an invalid response (not a `yes` or `no`).\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? confirm prompt \"([^\"]*)\".* answers? \"([^\"]*)\"`\n\nExample:\n\n```gherkin\n    Scenario: Invalid answer\n        Given I see a confirm prompt \"Confirm? (y/N)\", I answer \"nahhh\"\n        # Because the answer is invalid, survey will prompt again.\n        And then I see another confirm prompt \"Confirm? (y/N)\", I answer no\n\n        Then ask for confirm \"Confirm?\", receive no\n```\n\n#### Interrupt\n\nExpect to see a Confirm prompt and interrupt (^C).\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? confirm prompt \"([^\"]*)\".* interrupts?`\n\nExample:\n\n```gherkin\n    Scenario: Interrupted\n        Given I see a confirm prompt \"Confirm? (y/N)\", I interrupt\n\n        Then ask for confirm \"Confirm?\", get interrupted\n```\n\n#### With Help\n\nExpect to see a Confirm prompt, ask for help and then expect to see a Help message.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? confirm prompt \"([^\"]*)\".* asks? for help and sees? \"([^\"]*)\"`\n\nExample:\n\n```gherkin\n    Scenario: With help and receive a yes\n        Given I see a confirm prompt \"Confirm? [? for help] (y/N)\", I ask for help and see \"This action cannot be undone\"\n        And then I see another confirm prompt \"Confirm? (y/N)\", I answer yes\n\n        Then ask for confirm \"Confirm?\" with help \"This action cannot be undone\", receive yes\n```\n\n### Multiline\n\n#### No Answer\n\nExpect to see a Multiline prompt and give no answer.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? multiline prompt \"([^\"]*)\".* answers?: \"\"`\n\nExample:\n\n```gherkin\n    Scenario: Receive an empty answer\n        Given I see a multiline prompt \"Enter comment\", I answer \"\"\n\n        Then ask for multiline \"Enter comment\", receive:\n        \"\"\"\n        \"\"\"\n```\n\n#### Multiline Answer\n\nExpect to see a Multiline prompt and give an answer.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? multiline prompt \"([^\"]*)\".* answers?:`\n\nExample:\n\n```gherkin\n    Scenario: Receive a multiline answer\n        Given I see a multiline prompt \"Enter comment\", I answer:\n        \"\"\"\n        This is the first\n        line\n\n        this is the second line\n        \"\"\"\n\n        Then ask for multiline \"Enter comment\", receive:\n        \"\"\"\n        This is the first\n        line\n\n        this is the second line\n        \"\"\"\n```\n\n#### Interrupt\n\nExpect to see a Multiline prompt and interrupt (^C).\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? multiline prompt \"([^\"]*)\".* interrupts?`\n\nExample:\n\n```gherkin\n    Scenario: Interrupted\n        Given I see a multiline prompt \"Enter comment\", I interrupt\n\n        Then ask for multiline \"Enter comment\", get interrupted\n```\n\n### Password\n\n#### Answer\n\nExpect to see a Password prompt and answer it.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? password prompt \"([^\"]*)\".* answers? \"([^\"]*)\"`\n\nExample:\n\n```gherkin\n    Scenario: Receive an answer\n        Given I see a password prompt \"Enter password:\", I answer \"123456\"\n\n        Then ask for password \"Enter password:\", receive \"123456\"\n```\n\n#### Interrupt\n\nExpect to see a Password prompt and interrupt (^C).\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? password prompt \"([^\"]*)\".* interrupts?`\n\nExample:\n\n```gherkin\n    Scenario: Interrupted\n        Given I see a password prompt \"Enter password:\", I interrupt\n\n        Then ask for password \"Enter password:\", get interrupted\n```\n\n#### With Help\n\nExpect to see a Password prompt, ask for help and then expect to see a Help message.\n\nPattern: `(?:(?:get)|(?:see))s? a(?:nother)? password prompt \"([^\"]*)\".* asks? for help and sees? \"([^\"]*)\"`\n\nExample:\n\n```gherkin\n    Scenario: With help and receive an answer\n        Given I see a password prompt \"Enter password: [? for help]\", I ask for help and see \"It is a secret\"\n        And then I see another password prompt \"Enter password:\", I answer \"123456\"\n\n        Then ask for password \"Enter password:\" with help \"It is a secret\", receive \"123456\"\n```\n\n## Examples\n\n- Register for injection: https://github.com/nhatthm/surveysteps/blob/master/features/bootstrap/godog_test.go#L47\n- Inject: https://github.com/nhatthm/surveysteps/blob/master/features/bootstrap/survey.go#L36-L41\n- Use: https://github.com/nhatthm/surveysteps/blob/master/features/bootstrap/survey.go#L57\n\nFull suite: https://go.nhat.io/surveysteps/tree/master/features\n\n## Donation\n\nIf this project help you reduce time to develop, you can give me a cup of coffee :)\n\n### Paypal donation\n\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;or scan this\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1154587/113494222-ad8cb200-94e6-11eb-9ef3-eb883ada222a.png\" width=\"147px\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhatthm%2Fsurveysteps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhatthm%2Fsurveysteps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhatthm%2Fsurveysteps/lists"}