forked from HackYourFuture/JavaScript3
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfetch-repos-404.test.js
More file actions
31 lines (27 loc) · 931 Bytes
/
fetch-repos-404.test.js
File metadata and controls
31 lines (27 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const config = require('./config');
describe('Fetch repos 404 error handling', () => {
it('should render an HTTP error when fetching repos in the DOM', async () => {
await page.setRequestInterception(true);
page.on('request', req => {
if (config.blockedResourceTypes.includes(req.resourceType())) {
req.abort();
} else if (req.url().includes('/repos')) {
req.respond({
status: 404,
contentType: 'application/json',
body: JSON.stringify({
message: 'Not Found',
documentation_url: 'https://developer.github.com/v3',
}),
});
} else {
req.continue();
}
});
await page.goto(config.baseUrl, { waitUntil: 'networkidle0' });
const fetchErrorRendered = await page.evaluate(
() => document.querySelector('.alert-error') != null,
);
expect(fetchErrorRendered).toBe(true);
});
});