This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pm.sendRequest({ | |
url: '{{your url}}', | |
method: 'POST', | |
header: { | |
'Content-Type': 'multipart/form-data', | |
}, | |
body: { | |
mode: 'formdata', | |
formdata: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pm.sendRequest({ | |
url: environment.host + "url" + environment.a_signup + "url", | |
method: 'GET', | |
}, function(err, response) { | |
//запись в переменную ответа | |
var code = response.json(); | |
//копирование в переменную код юзера | |
pm.environment.set("code_signup", code.code); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var random_id = parseInt(Math.random() * 10000); | |
pm.environment.set("random_id", random_id); | |
var domain = pm.environment.get("domain"); | |
pm.sendRequest({ | |
url: "https://api"+domain+"./signup", | |
method: 'POST', | |
header: { | |
'Content-Type': 'application/json', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr_timezone = ["Africa/Tunis" , "Asia/Gaza" , "America/Costa_Rica", "America/Puerto_Rico" , "Atlantic/Cape_Verde" , "Europe/London" , "Europe/Dublin" , "Europe/Oslo" , "Europe/Rome"]; | |
var rand_arr_timezone = Math.floor(Math.random() * arr_timezone.length); | |
var alert_rand_arr_timezone = arr_timezone[rand_arr_timezone]; | |
pm.environment.set("alert_rand_arr_timezone", alert_rand_arr_timezone); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.server() | |
cy.route({ | |
url: '/users?approved=true', | |
status: 200, | |
response: 'fixture:empty.user.json' | |
}).as('approved') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await cy.server(); | |
await cy.route({ | |
method: 'POST', | |
url: 'users', | |
response: {name: 'mocked user'} | |
}); | |
await cy.addUser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.server(); | |
cy.route(url:'POST', response:'/users').as(alias:'addUser'); | |
cy.wait(alias:'@addUser').should((xhr) => { | |
expect(xhr.responseBody).to.include('name') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.server(); | |
cy.route(url:'POST', response:'/users').as(alias:'addUser'); | |
cy.wait(alias:'@addUser').should((xhr) => { | |
expect(xhr.responseBody.name).to.eq('name') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.server(); | |
cy.route(url:'POST', response:'/users').as(alias:'addUser'); | |
cy.wait(alias:'@addUser').should((xhr) => { | |
expect(xhr.responseBody.name).to.eq('name') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'cypress-file-upload'; | |
Cypress.Commands.add('uploadFile', (fileName, input, mime) => { | |
cy.fixture(fileName).then(fileContent => { | |
cy.get(input).upload( | |
{ fileContent, fileName, mimeType: mime }, | |
{ subjectType: 'input' },); | |
}); | |
}) |
NewerOlder