Skip to content
Snippets Groups Projects
Commit c5b861be authored by richard.petersen's avatar richard.petersen :sailboat:
Browse files

Deshakerize unit test

parent e51075cf
No related branches found
No related tags found
No related merge requests found
......@@ -66,22 +66,30 @@ describe('UI Middleware', function () {
})
it('refreshes manifest data after caching timeout', async function () {
process.env.CACHE_TTL = 1
process.env.CACHE_TTL = 0
app = await mockApp()
const response = await request(app).get('/manifests')
expect(response.statusCode).to.equal(200)
expect(response.body).to.deep.equal([{ namespace: 'test', path: 'example' }])
fetchConfig['http://ui-server'] = {
'/manifest.json': generateSimpleViteManifest({ 'example.js': 'other' }),
'/example.js': ''
}
const refreshedCache = new Promise(resolve => {
fetchConfig['http://ui-server'] = {
'/manifest.json': generateSimpleViteManifest({ 'example.js': 'other' }),
'/example.js': () => {
try {
return new Response('new content')
} finally {
resolve()
}
}
}
})
// trigger update
await request(app).get('/manifests')
// wait some time
await new Promise(resolve => setTimeout(resolve, 10))
await refreshedCache
const response2 = await request(app).get('/manifests')
expect(response2.statusCode).to.equal(200)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment