1 import assert from '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&mock_api_error=fetch');
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('Error fetching data from'));
24 describe('HTTP 200 - JSON parsing fails', function () {
25 before(async function () {
26 page = await browser.newPage();
27 await page.goto('http://localhost:9999/search.html?q=london&mock_api_error=parse');
30 after(async function () {
34 it('should display an error', async function () {
35 await page.waitForSelector('#error');
37 let message = await page.$eval('#error', el => el.textContent);
38 assert.ok(message.includes('Error parsing JSON data from'));