{"id":15552877,"url":"https://github.com/bahmutov/cypress-example-forms","last_synced_at":"2025-09-28T23:31:36.164Z","repository":{"id":36351442,"uuid":"212583697","full_name":"bahmutov/cypress-example-forms","owner":"bahmutov","description":"Example Cypress test for multi-page form","archived":false,"fork":false,"pushed_at":"2024-12-17T23:51:09.000Z","size":1411,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-27T20:12:42.159Z","etag":null,"topics":["cypress","cypress-example"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-10-03T13:12:01.000Z","updated_at":"2022-11-26T14:23:56.000Z","dependencies_parsed_at":"2023-01-17T00:43:10.248Z","dependency_job_id":"4394aa6d-995b-4284-a347-ace602b7823f","html_url":"https://github.com/bahmutov/cypress-example-forms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-example-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-example-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-example-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-example-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/cypress-example-forms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234571075,"owners_count":18854269,"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":["cypress","cypress-example"],"created_at":"2024-10-02T14:22:52.560Z","updated_at":"2025-09-28T23:31:35.588Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cypress-example-forms [![renovate-app badge][renovate-badge]][renovate-app] [![CircleCI](https://circleci.com/gh/bahmutov/cypress-example-forms/tree/master.svg?style=svg)](https://circleci.com/gh/bahmutov/cypress-example-forms/tree/master) ![cypress version](https://img.shields.io/badge/cypress-9.7.0-brightgreen) ![cypress-react-app-actions version](https://img.shields.io/badge/cypress--react--app--actions-1.0.2-brightgreen)\n\nForms component is [uniforms](https://uniforms.tools/docs/tutorials-basic-uniforms-usage)\n\n- [single-test.js](cypress/integration/single-test.js) shows a single long test that goes through the 3 pages of the form.\n- [three-tests.js](cypress/integration/three-tests.js) splits this long test into 3 tests. Each test ends by confirming the internal application state, then a new test starts by setting that state. This sets the second test at the same checkpoint _as if the test went through the user interface_.\n- [actions.js](./cypress/integration/actions.js) shows even better approach to controlling the application's state from the tests using [cypress-react-app-actions](https://github.com/bahmutov/cypress-react-app-actions) plugin, read \"[Control React Applications From Cypress Tests](https://glebbahmutov.com/blog/react-app-actions/)\".\n\nMain points\n\nApplication exposes its reference by setting it on the `window` object.\n\n```js\n// application code\nclass MasterForm extends React.Component {\n  constructor (props) {\n    super(props)\n    if (window.Cypress) {\n      window.app = this\n    }\n  }\n  ...\n}\n```\n\nThen the first test ends with a known state - we assert the internal state object.\n\n```js\n// end of the first test\nconst startOfSecondPageState = {...}\ncy.contains('Next').click()\n\ncy.log('Second page')\ncy.contains('h1', 'Book Hotel 2')\ncy.window()\n  .its('app.state')\n  .should('deep.equal', startOfSecondPageState)\n```\n\nThe second test starts by visiting the application page and setting the state object.\n\n```js\n// start of the second test\ncy.window().its('app').invoke('setState', startOfSecondPageState)\n\ncy.log('Second page')\ncy.contains('h1', 'Book Hotel 2')\n```\n\nOnce the test invokes the `app.setState(...)` it \"becomes\" exactly as if the test went through the user interface filling the first page.\n\n![Start of the second test](images/start-of-second-test.gif)\n\nSee more notes about this direct access from the Cypress test to the application in [Stop using Page Objects and Start using App Actions](https://www.cypress.io/blog/2019/01/03/stop-using-page-objects-and-start-using-app-actions/).\n\n## License\n\nThis project is licensed under the terms of the [MIT license](/LICENSE.md).\n\n[renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg\n[renovate-app]: https://renovateapp.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-example-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fcypress-example-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-example-forms/lists"}