diff --git a/spec/server_test.js b/spec/server_test.js
index 08c4afa8ae40b8542a63b98f742c8f3f7bf80741..cc7592fb505d343259c5bc00a4025808529a0e34 100644
--- a/spec/server_test.js
+++ b/spec/server_test.js
@@ -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)