diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6a303e8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "args": [ + "task" + ], + "name": "Gulp task", + "program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "node" + } + + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 41350df..80748fe 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ Cypress plugin for effective API testing. ### Installation -### Usage \ No newline at end of file +### Usage diff --git a/cypress/e2e/.ipynb_checkpoints/api.cy-checkpoint.ts b/cypress/e2e/.ipynb_checkpoints/api.cy-checkpoint.ts new file mode 100644 index 0000000..a0a52eb --- /dev/null +++ b/cypress/e2e/.ipynb_checkpoints/api.cy-checkpoint.ts @@ -0,0 +1,68 @@ +const methods = ['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'] + +it(`works with different methods`, () => { + + methods.forEach(method => { + cy.api({ + method, + url: '/' + }) + + }); + +}) + +it('works with query string', () => { + + cy.api({ + method: 'GET', + url: '/', + qs: { + listId: 1 + } + }).its('status') + .should('eq', 200) + + cy.get('[data-cy=query]') + .should('be.visible') + +}); + +it('works with headers', () => { + + cy.api({ + method: 'GET', + url: '/', + headers: { + 'accept': 'application/json' + } + }) + + cy.get('[data-cy=requestHeaders]') + .should('be.visible') + +}); + +it('shows failed status code', () => { + + cy.api({ + url: '/404', + failOnStatusCode: false + }) + + cy.get('[data-cy=status]') + .eq(0) + .should('be.visible') + .and('contain', '404') + + cy.api({ + url: '/400', + failOnStatusCode: false + }) + + cy.get('[data-cy=status]') + .eq(1) + .should('be.visible') + .and('contain', '400') + +}); diff --git a/cypress/e2e/.ipynb_checkpoints/formats.cy-checkpoint.ts b/cypress/e2e/.ipynb_checkpoints/formats.cy-checkpoint.ts new file mode 100644 index 0000000..caddff2 --- /dev/null +++ b/cypress/e2e/.ipynb_checkpoints/formats.cy-checkpoint.ts @@ -0,0 +1,23 @@ +it('works with xml', () => { + + cy.api({ + url: '/xml' + }) + +}); + +it('works with html', () => { + + cy.api({ + url: '/html' + }) + +}); + +it('works with json', () => { + + cy.api({ + url: '/json' + }) + +}); \ No newline at end of file