--description--
As a reminder, this project is being built upon the following starter project on Gitpod, or cloned from GitHub.
--instructions--
Within tests/2_functional-tests.js
, alter the 'Test GET /hello with your name'
test (// #2
) to assert the status
and the text
of the response to make the test pass.
Send your name as a URL query by appending ?name=<your_name>
to the route. The endpoint responds with 'hello <your_name>'
.
--hints--
All tests should pass
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
You should test for res.status
== 200
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
(data) => {
assert.equal(data.assertions[0].method, 'equal');
assert.equal(data.assertions[0].args[0], 'res.status');
assert.equal(data.assertions[0].args[1], '200');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
You should test for res.text
== 'hello <your_name>'
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
(data) => {
assert.equal(data.assertions[1].method, 'equal');
assert.equal(data.assertions[1].args[0], 'res.text');
assert.match(data.assertions[1].args[1], /hello [\w\d_-]/);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);