1 const assert = require('assert');
3 describe('Nominatim API errors', function () {
6 describe('HTTP 503 - service unavailable', function () {
7 before(async function () {
8 page = await browser.newPage();
9 await page.goto('http://localhost:9999/search.html?q=london&httpbin_status=503');
12 after(async function () {
16 it('should display an error', async function () {
17 await page.waitForSelector('#error');
19 let message = await page.$eval('#error', el => el.textContent);
20 assert.ok(message.includes('httpbin.org'));
21 assert.ok(message.includes('Error fetching data from'));
25 describe('HTTP 200 - JSON parsing fails', function () {
26 before(async function () {
27 page = await browser.newPage();
28 await page.goto('http://localhost:9999/search.html?q=london&httpbin_status=200');
31 after(async function () {
35 it('should display an error', async function () {
36 await page.waitForSelector('#error');
38 let message = await page.$eval('#error', el => el.textContent);
39 assert.ok(message.includes('httpbin.org'));
40 assert.ok(message.includes('Error parsing JSON data from'));