3.3 KiB
3.3 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5f8884f4c46685731aabfc41 | Eseguire test funzionali usando un headless browser II | 2 | 301594 | run-functional-tests-using-a-headless-browser-ii |
--description--
Come promemoria, questo progetto verrà costruito a partire dalla seguente bozza su Replit, o clonato da GitHub.
--instructions--
All'interno di tests/2_functional-tests.js
, nel test 'submit "surname" : "Vespucci" - write your e2e test...'
(// #6
), automatizza la compilazione e invia il modulo:
- Compila il modulo con il
surname
diVespucci
- Invia premendo il pulsante
'submit'
All'interno della callback:
- asserisci che lo stato è
200
- asserisci che il testo all'interno dell'elemento
span#name
è'Amerigo'
- asserisci che il testo all'interno dell'elemento
span#surname
è'Vespucci'
- asserisci che gli elementi
span#dates
esistono e il loro conteggio è1
Non dimenticare di rimuovere la chiamata assert.fail()
.
--hints--
Tutti i test dovrebbero essere superati.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti asserire che la richiesta dell'headless browser sia riuscita.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
(data) => {
assert.equal(data.assertions[0].method, 'browser.success');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti asserire che il testo all'interno dell'elemento 'span#name' sia 'Amerigo'.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
(data) => {
assert.equal(data.assertions[1].method, 'browser.text');
assert.match(data.assertions[1].args[0], /('|")span#name\1/);
assert.match(data.assertions[1].args[1], /('|")Amerigo\1/);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti asserire che il testo all'interno dell'elemento 'span#surname' sia 'Vespucci'.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
(data) => {
assert.equal(data.assertions[2].method, 'browser.text');
assert.match(data.assertions[2].args[0], /('|")span#surname\1/);
assert.match(data.assertions[2].args[1], /('|")Vespucci\1/);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti asserire che l'elemento 'span#dates' esista e il suo conteggio sia 1.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
(data) => {
assert.equal(data.assertions[3].method, 'browser.elements');
assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
assert.equal(data.assertions[3].args[1], 1);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
--solutions--
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/