Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Commit 54109c3

Browse files
committed
FE-245-agregar-doc-cypress auto-commit
1 parent a9eabec commit 54109c3

File tree

3 files changed

+249
-11
lines changed

3 files changed

+249
-11
lines changed

Diff for: README.md

+74
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,80 @@ yarn serve
6464

6565
We use as backend [Json Api Playground](http://jsonapiplayground.reyesoft.com/).
6666

67+
## Running cypress test in console
68+
69+
```bash
70+
yarn cy:run
71+
```
72+
73+
## Running cypress test in browser
74+
75+
```bash
76+
yarn cy:open
77+
```
78+
79+
## Creating a test
80+
81+
Go to the following location cypress -> integration, and create a file with the extension .spec.ts. The file contains the following structure:
82+
83+
```
84+
describe('ListBase', () => {
85+
before(() => {
86+
cy.disableScreenshot();
87+
});
88+
it('ListBase integrity test', () => {
89+
cy.spyAuthors();
90+
cy.visit('/#/authors?pageSize=10');
91+
})
92+
});
93+
```
94+
95+
## Simulate backend response in cypress
96+
97+
Go to the following location cypress -> fixtures, and create a file with the extension .json. In it we will have the supposed response from the backend.
98+
99+
```
100+
{
101+
"meta": {
102+
"page": 1,
103+
"resources_per_page": 10,
104+
"total_resources": 11
105+
},
106+
"data": [
107+
{
108+
"type": "authors",
109+
"id": "14",
110+
"attributes": {
111+
"name": "Anais Carroll",
112+
"birthplace": "Taiwan",
113+
"date_of_birth": "1986-08-12",
114+
"date_of_death": "2000-10-05"
115+
},
116+
"relationships": {
117+
"photos": {
118+
"data": []
119+
},
120+
"books": {
121+
"data": [
122+
{
123+
"type": "books",
124+
"id": "23"
125+
},
126+
{
127+
"type": "books",
128+
"id": "49"
129+
}
130+
]
131+
}
132+
},
133+
"links": {
134+
"self": "/authors/14"
135+
}
136+
}
137+
]
138+
}
139+
```
140+
67141
## Colaborate
68142

69143
Check [Environment development file](DEV_ENVIRONMENT.md) 😉.

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "ngx-jsonapi-material-app",
33
"scripts": {
44
"build_lib": "ng build --prod ngx-jsonapi-material",
5-
"cy:open": "cypress open",
5+
"cy:run": "start-server-and-test start :4200 'cypress run'",
6+
"cy:open": "start-server-and-test start :4200 'cypress open'",
67
"npm_pack": "cd dist/ngx-jsonapi-material && npm pack",
78
"copy-license": "copy .\\LICENSE .\\dist\\ngx-jsonapi-material",
89
"copy-readme": "copy .\\README.md .\\dist\\ngx-jsonapi-material",
@@ -181,6 +182,7 @@
181182
"rollup": "^0.50.0",
182183
"rxjs-tslint-rules": "4.7.2",
183184
"sorcery": "^0.10.0",
185+
"start-server-and-test": "^1.11.7",
184186
"ts-mockito": "^2.3.1",
185187
"ts-node": "~5.0.1",
186188
"tsickle": ">=0.25.5",

0 commit comments

Comments
 (0)