Skip to content

Commit a7a919d

Browse files
authored
Add recipe for blog about page objects and application actions (#219)
* initial todomvc * add typescript for createDefaultTodos and createTodo custom commands * trying going through model * page actions * more work * refactor toggle * routing should use actions * disable codepen recipe on CI (#216) * use cy state to get document * add element coverage to the table * disable codepen recipe for now * rename to application actions folder * testing individual errors * playing with window * add recipe to readme * selectors in closures * refactor * move allItems into utils * example spying on method call
1 parent d720434 commit a7a919d

File tree

26 files changed

+40201
-0
lines changed

26 files changed

+40201
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Recipe | Category | Description
1515
[Drag and Drop](#drag-and-drop) | Testing the DOM | Use `.trigger()` to test drag and drop
1616
[Typescript with Browserify](#typescript-with-browserify) | Preprocessors | Add typescript support with browserify
1717
[Typescript with Webpack](#typescript-with-webpack) | Preprocessors | Add typescript support with webpack
18+
[Application Actions](#application-actions) | Blogs | Application actions are a replacement for Page Objects
1819
[Direct Control of AngularJS](#direct-control-of-angularjs) | Blogs | Bypass the DOM and control AngularJS
1920
[E2E API Testing](#e2e-api-testing) | Blogs | Run your API Tests with a GUI
2021
[E2E Snapshots](#e2e-snapshots) | Blogs | End-to-End Snapshot Testing
@@ -182,6 +183,12 @@ Get around the lack of a `.hover()` command.
182183
- Use [`@cypress/webpack-preprocessor`](https://github.com/cypress-io/cypress-webpack-preprocessor) to write Cypress tests in Typescript
183184
- Lint TypeScript spec code against Cypress type definitions
184185

186+
### [Application Actions](./examples/blogs__application-actions)
187+
188+
- Invoke methods on the application's model object
189+
- Avoid code duplication and need to create page object hierarchy
190+
- Run e2e very quickly by skipping UI unless testing that specific UI feature
191+
185192
### [Direct Control of AngularJS](./examples/blogs__direct-control-angular)
186193

187194
- [Blog article written here](https://www.cypress.io/blog/2017/11/15/Control-Angular-Application-From-E2E-Tests)

circle.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
- .cache/Cypress
5252

5353
# define a new job with defailts for each "examples/*" subfolder
54+
blogs__application-actions:
55+
<<: *defaults
5456
blogs__codepen-demo:
5557
<<: *defaults
5658
blogs__direct-control-angular:
@@ -118,6 +120,9 @@ workflows:
118120
# - blogs__codepen-demo:
119121
# requires:
120122
# - build
123+
- blogs__application-actions:
124+
requires:
125+
- build
121126
- blogs__direct-control-angular:
122127
requires:
123128
- build
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SKIP_PREFLIGHT_CHECK=true
2+
BROWSER=none
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Application Actions
2+
3+
Application actions are a replacement for Page Objects
4+
5+
## Shows how to
6+
7+
- Invoke methods on the application's model object
8+
- Avoid code duplication and need to create page object hierarchy
9+
- Run e2e very quickly by skipping UI unless testing that specific UI feature
10+
11+
## Blog post
12+
13+
`Stop using Page Objects and Start using Application Actions`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:8888",
3+
"ignoreTestFiles": "utils.js"
4+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"id": 0,
4+
"text": "first",
5+
"completed": true
6+
},
7+
{
8+
"id": 1,
9+
"text": "second",
10+
"completed": false
11+
},
12+
{
13+
"id": 2,
14+
"text": "third",
15+
"completed": true
16+
}
17+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

0 commit comments

Comments
 (0)