-
Run below command in terminal to install the node dependencies locally
npm ci
-
Run below command to check installed cypress version
npx cypress verify
cy.performSpaceXOperations(options, logOptions= {})
options | description | required |
---|---|---|
query | graphqlQuery | Y |
variables | graphqlVariables | N (optional) |
url | endpoint | Y |
method | POST/GET | Y (POST by default) |
headers | headers to pass for request | N (set to "Content-Type": "application/json" by default) (optional) |
method | POST/GET | N (POST by default) (optional) |
failOnStatusCode | failOnStatusCode | N (false by default) (optional) |
options | description | default message |
---|---|---|
displayName | display name for request | GrapQL Request |
message | message | Performing GraphQL Request |
name | name | performGraphQLRequest |
autoEnd | autoEnd logging | true |
cy.getRequest(options, logOptions= {})
options | description | required |
---|---|---|
url | endpoint | Y |
query | query Params (type: Object) |
N ({} by default) (optional) |
headers | headers to pass for request | N (set to "Content-Type": "application/json" by default) (optional) |
log | logging info | N (true by default) (optional) |
failOnStatusCode | failOnStatusCode | N (false by default) (optional) |
options | description | default message |
---|---|---|
displayName | display name for request | Get Request |
message | message | Performing Get Request |
name | name | performGetRequest |
autoEnd | autoEnd logging | true |
cy.postRequest(options, logOptions= {})
options | description | required |
---|---|---|
url | endpoint | Y |
body | Request Body`(Object | String)` |
headers | headers to pass for request | N (set to "Content-Type": "application/json" by default) (optional) |
log | logging info | N (true by default) (optional) |
failOnStatusCode | failOnStatusCode | N (false by default) (optional) |
options | description | default message |
---|---|---|
displayName | display name for request | Post Request |
message | message | Performing Post Request |
name | name | performPostRequest |
autoEnd | autoEnd logging | true |
cy.deleteRequest(options, logOptions= {})
options | description | required |
---|---|---|
url | endpoint | Y |
body | Request Body `(Object | String |
headers | headers to pass for request | N (set to "Content-Type": "application/json" by default) (optional) |
log | logging info | N (true by default) (optional) |
failOnStatusCode | failOnStatusCode | N (false by default) (optional) |
options | description | default message |
---|---|---|
displayName | display name for request | Delete Request |
message | message | Performing Delete Request |
name | name | performDeleteRequest |
autoEnd | autoEnd logging | true |
cy.putRequest(options, logOptions= {})
options | description | required |
---|---|---|
url | endpoint | Y |
body | Request Body `(Object | String |
headers | headers to pass for request | N (set to "Content-Type": "application/json" by default) (optional) |
log | logging info | N (true by default) (optional) |
failOnStatusCode | failOnStatusCode | N (false by default) (optional) |
options | description | default message |
---|---|---|
displayName | display name for request | Put Request |
message | message | Performing Put Request |
name | name | performPutRequest |
autoEnd | autoEnd logging | true |
(Back to top)
Specs are written under cypress/e2e folder.
Rest API tests can be found under api rest
folder.
GraphQL can be found under api graphql
folder.
Tests can be executed either via command line or from test runner.
- Run below command in terminal to run the tests from command line.
npm run test -- --reporter mochawesome --reporter-options reportDir="cypress/results",overwrite=false,html=false,json=true
- To run the test with test runner, run the below command and execute the tests that you need to run from the test runner UI.
npx cypress open
Note : If you want to see how to execute all the tests from cypress test runner , refer to this repository https://github.com/jeeshan12/cypress-run-all-specs.git
Note: In progress. Will be released soon You can run the tests using Docker as well. To do this
- You need to build the image using the command.
docker build -t <<imageTag>> .
<> is the name of the image. Generally your dockerusername followed by the name of the image. It's not mandate but a good practice to name your image like this. For me command will look like this
docker build -t jeeshan12 .
-
Once image is build you can now execute the tests in container by running the below command
docker run --rm <<imageTag>> npm run test -- --reporter mochawesome --reporter-options reportDir="cypress/results",overwrite=false,html=false,json=true
If you want to start the container in intercative mode run the below command
docker run --rm -it <<imageTag>> /bin/bash
Above command starts the conatiner in intercative mode with bash. Now you can debug and explore more inside the container.
Above commands will automatically removes the container after execution.
To remove all the stopped containers you can run the command
docker rm $(docker ps -a -q)
Uses mochawesome-report-generator https://www.npmjs.com/package/mochawesome-report-generator
and mochawesome https://www.npmjs.com/package/mochawesome
for reporting. There is no specific configuration needs to be done at framework level. Report options are handled in test
scripts in package.json. If you are intersted to do some configuration changes, you can easily do the changes in test
script command.