* fix: update mocha chai challenge text, code snippets * fix: add expected output values to instructions * fix: reword instructions a little bit * fix: adjust challenge test for new test suite in boilerpplate Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com>
3.2 KiB
3.2 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5f8884f4c46685731aabfc41 | Run Functional Tests Using a Headless Browser II | 2 | 301594 | run-functional-tests-using-a-headless-browser-ii |
--description--
As a reminder, this project is being built upon the following starter project on Replit, or cloned from GitHub.
--instructions--
Within tests/2_functional-tests.js
, in the 'Submit the surname "Vespucci" in the HTML form'
test (// #5
), automate the following:
- Fill in the form with the surname
Vespucci
- Press the submit button
And within the pressButton
callback:
- Assert that status is OK
200
- Assert that the text inside the element
span#name
is'Amerigo'
- Assert that the text inside the element
span#surname
is'Vespucci'
- Assert that the element(s)
span#dates
exist and their count is1
Do not forget to remove the assert.fail()
call.
--hints--
All tests should pass.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
You should assert that the headless browser request succeeded.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.assertions[0].method, 'browser.success');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
You should assert that the text inside the element span#name
is 'Amerigo'
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').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);
}
);
You should assert that the text inside the element span#surname
is 'Vespucci'
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').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);
}
);
You should assert that the element span#dates
exist and its count is 1.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').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.
*/