|
1 | 1 | # Cypress.io with Patterns
|
2 | 2 |
|
3 |
| - Using Cypress to handle automation tests implementing Page Objects and Screenplay patterns. |
| 3 | +Using Cypress to handle automation tests implementing Page Objects and Screenplay patterns. |
4 | 4 |
|
5 | 5 | ## BDD Features with Gherkin
|
6 | 6 |
|
7 | 7 | The goal was to develop automation tests to the simple list app available at http://repo-listing.web.app
|
8 | 8 |
|
9 | 9 | To achieve that, Gherkin features lead the way of thinking the core features of that system. Given/When/Then strategy was used here:
|
10 | 10 |
|
11 |
| -* [_adicionar.feature_](./features/adicionar.feature) |
12 |
| -* [_remover.feature_](./features/remover.feature) |
| 11 | +- [_adicionar.feature_](./features/adicionar.feature) |
| 12 | +- [_remover.feature_](./features/remover.feature) |
13 | 13 |
|
14 | 14 | ## Page objects pattern
|
15 | 15 |
|
16 | 16 | Development with this pattern was done under the branch [feature/page-objects](https://github.com/thiagojacinto/cypress-with-patterns/tree/feature/page-objects).
|
17 | 17 |
|
18 |
| -> Objeto _Home_: |
| 18 | +> Object _Home_: |
| 19 | +
|
| 20 | +- [support/](./cypress/support) |
| 21 | + - [pageObjects/](./cypress/support/pageObjects) |
| 22 | + - [Home/](./cypress/support/pageObjects/Home) |
| 23 | + - [elements.components.js](./cypress/support/pageObjects/Home/elements.components.js) |
| 24 | + - [index.js](./cypress/support/pageObjects/Home/index.js) |
| 25 | + |
| 26 | +> Tests: |
| 27 | +
|
| 28 | +- [integration/](./cypress/integration) |
| 29 | + - [page-objects/](./cypress/integration/page-objects) |
| 30 | + - [adicionar.spec.js](./cypress/integration/page-objects/adicionar.spec.js) |
| 31 | + - [remover.spec.js](./cypress/integration/page-objects/remover.spec.js) |
| 32 | + |
| 33 | +## Screenplay pattern |
| 34 | + |
| 35 | +Implementation of this pattern was developed after the page object approuch. Another strategy was using fixture to handle import data from external file (ex: json) and randomize inputs. |
| 36 | + |
| 37 | +> Fixture: |
| 38 | +
|
| 39 | +* [fixtures/](./cypress/fixtures) |
| 40 | + * [repositorios.json](./cypress/fixtures/repositorios.json) |
| 41 | + |
| 42 | +> _Screenplay pattern_ base files: |
| 43 | +
|
| 44 | +Five original blocks were simplified to 3: [Actor](./cypress/support/screenplay/agente/Agente.js), [Task](./cypress/support/screenplay/tarefa/Tarefa.js) and [Questions](./cypress/support/screenplay/dado-quando-entao/DadoQuandoEntao.js), here translated to _Agente, Tarefa_ e _DadoQuandoEntao_, respectively. |
| 45 | + |
19 | 46 | * [support/](./cypress/support)
|
20 |
| - * [pageObjects/](./cypress/support/pageObjects) |
21 |
| - * [Home/](./cypress/support/pageObjects/Home) |
22 |
| - * [elements.components.js](./cypress/support/pageObjects/Home/elements.components.js) |
23 |
| - * [index.js](./cypress/support/pageObjects/Home/index.js) |
| 47 | + * [screenplay/](./cypress/support/screenplay) |
| 48 | + * [agente/](./cypress/support/screenplay/agente) |
| 49 | + * [Agente.js](./cypress/support/screenplay/agente/Agente.js) |
| 50 | + * [Usuario.js](./cypress/support/screenplay/agente/Usuario.js) |
| 51 | + * [index.js](./cypress/support/screenplay/agente/index.js) |
| 52 | + * [dado-quando-entao/](./cypress/support/screenplay/dado-quando-entao) |
| 53 | + * [DadoQuandoEntao.js](./cypress/support/screenplay/dado-quando-entao/DadoQuandoEntao.js) |
| 54 | + * [index.js](./cypress/support/screenplay/dado-quando-entao/index.js) |
| 55 | + * [tarefa/](./cypress/support/screenplay/tarefa) |
| 56 | + * [Tarefa.js](./cypress/support/screenplay/tarefa/Tarefa.js) |
| 57 | + * [index.js](./cypress/support/screenplay/tarefa/index.js) |
| 58 | + * [utils/](./cypress/support/screenplay/utils) |
| 59 | + * [index.js](./cypress/support/screenplay/utils/index.js) |
| 60 | + * [naoImplementado.error.js](./cypress/support/screenplay/utils/naoImplementado.error.js) |
| 61 | + * [ScreenplayItem.js](./cypress/support/screenplay/ScreenplayItem.js) |
| 62 | + * [index.js](./cypress/support/screenplay/index.js) |
| 63 | + |
| 64 | +> Tests: |
24 | 65 |
|
25 |
| -> Testes: |
26 | 66 | * [integration/](./cypress/integration)
|
27 |
| - * [page-objects/](./cypress/integration/page-objects) |
28 |
| - * [adicionar.spec.js](./cypress/integration/page-objects/adicionar.spec.js) |
29 |
| - * [remover.spec.js](./cypress/integration/page-objects/remover.spec.js) |
| 67 | + * [screenplay/](./cypress/integration/screenplay) |
| 68 | + * [Tarefas/](./cypress/integration/screenplay/Tarefas) |
| 69 | + * [AcessarHome.tarefa.js](./cypress/integration/screenplay/Tarefas/AcessarHome.tarefa.js) |
| 70 | + * [AdicionarValorVazio.tarefa.js](./cypress/integration/screenplay/Tarefas/AdicionarValorVazio.tarefa.js) |
| 71 | + * [EsperarListaContendoDoisItens.tarefa.js](./cypress/integration/screenplay/Tarefas/EsperarListaContendoDoisItens.tarefa.js) |
| 72 | + * [EsperarListaContendoUmItem.tarefa.js](./cypress/integration/screenplay/Tarefas/EsperarListaContendoUmItem.tarefa.js) |
| 73 | + * [ExibirLista.tarefa.js](./cypress/integration/screenplay/Tarefas/ExibirLista.tarefa.js) |
| 74 | + * [ExibirListaContendoTres.tarefa.js](./cypress/integration/screenplay/Tarefas/ExibirListaContendoTres.tarefa.js) |
| 75 | + * [InserirNovoRepositorio.tarefa.js](./cypress/integration/screenplay/Tarefas/InserirNovoRepositorio.tarefa.js) |
| 76 | + * [LimparLista.tarefa.js](./cypress/integration/screenplay/Tarefas/LimparLista.tarefa.js) |
| 77 | + * [RemoverItem.tarefa.js](./cypress/integration/screenplay/Tarefas/RemoverItem.tarefa.js) |
| 78 | + * [VisualizarListaComItens.tarefa.js](./cypress/integration/screenplay/Tarefas/VisualizarListaComItems.tarefa.js) |
| 79 | + * [VisualizarListaVazia.tarefa.js](./cypress/integration/screenplay/Tarefas/VisualizarListaVazia.tarefa.js) |
| 80 | + * [index.js](./cypress/integration/screenplay/Tarefas/index.js) |
| 81 | + * [adicionar/](./cypress/integration/screenplay/adicionar) |
| 82 | + * [adicionar.screenplay.spec.js](./cypress/integration/screenplay/adicionar/adicionar.screenplay.spec.js) |
| 83 | + * [componentes/](./cypress/integration/screenplay/componentes) |
| 84 | + * [home.componentes.js](./cypress/integration/screenplay/componentes/home.componentes.js) |
| 85 | + * [remover/](./cypress/integration/screenplay/remover) |
| 86 | + * [remover.screenplay.spec.js](./cypress/integration/screenplay/remover/remover.screenplay.spec.js) |
| 87 | + |
| 88 | +## Lint and precommit hook |
| 89 | + |
| 90 | +This project uses ESLint, Prettier and lint-staged to handle linting operations and precommit hook. |
| 91 | + |
| 92 | +Before hands-on, do not forget to run: |
| 93 | + |
| 94 | +``` |
| 95 | +npm install |
| 96 | +npx mrm lint-staged |
| 97 | +``` |
0 commit comments