From 5c45741a9d40ae5c0d748858054ece2ac262a4bb Mon Sep 17 00:00:00 2001 From: Vadim Kovalenko Date: Mon, 13 Nov 2023 21:11:16 +0200 Subject: [PATCH] Quick fix for the forceRender test --- test/e2e/forceRender.test.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/e2e/forceRender.test.ts b/test/e2e/forceRender.test.ts index 21b710f6..ef1d8860 100644 --- a/test/e2e/forceRender.test.ts +++ b/test/e2e/forceRender.test.ts @@ -20,8 +20,12 @@ describe('forceRender', () => { mwActionApiPath: 'w/api.php', } - beforeAll(async () => { + afterAll(async () => { await execa('redis-cli flushall', { shell: true }) + rimraf.sync(`./${testId}`) + const redisScan = await execa('redis-cli --scan', { shell: true }) + // Redis has been cleared + expect(redisScan.stdout).toEqual('') }) test('Scrape article from bm.wikipedia.org using WikimediaDesktop render', async () => { @@ -33,24 +37,23 @@ describe('forceRender', () => { } else { console.log('Zimcheck not installed, skipping test') } - - rimraf.sync(`./${testId}`) - const redisScan = await execa('redis-cli --scan', { shell: true }) - // Redis has been cleared - expect(redisScan.stdout).toEqual('') }) test('Scrape article from bm.wikipedia.org should throw error when using VisualEditor render', async () => { const forceRender = 'VisualEditor' - expect(async () => { + try { await mwoffliner.execute({ ...parameters, forceRender }) - }).rejects.toThrowError() + } catch (err) { + expect(err).toReturn() + } }) test('Scrape article from bm.wikipedia.org should throw error when using wrong render', async () => { const forceRender = 'unknownRenderName' - expect(async () => { + try { await mwoffliner.execute({ ...parameters, forceRender }) - }).rejects.toThrowError() + } catch (err) { + expect(err.message).toEqual('Unable to find specific API end-point to retrieve article HTML') + } }) })