From 42ed85b3e263bb5e28725395924d0b595e1e0041 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 16 Aug 2023 13:28:57 -0500 Subject: [PATCH] Fix flaky Cloudflare test (#8103) * chore: fix flaky CF test * chore: increase wrangler timeout --- packages/integrations/cloudflare/test/cf.test.js | 5 +---- .../cloudflare/test/fixtures/cf/src/pages/index.astro | 2 +- .../cloudflare/test/fixtures/runtime/src/pages/index.astro | 2 +- packages/integrations/cloudflare/test/runtime.test.js | 2 +- packages/integrations/cloudflare/test/test-utils.js | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/integrations/cloudflare/test/cf.test.js b/packages/integrations/cloudflare/test/cf.test.js index b671f41e9..ec0e52c97 100644 --- a/packages/integrations/cloudflare/test/cf.test.js +++ b/packages/integrations/cloudflare/test/cf.test.js @@ -31,10 +31,7 @@ describe('Cf metadata and caches', () => { let html = await res.text(); let $ = cheerio.load(html); - expect($('#cf').text()).to.contain( - 'city', - `Expected "city" to exist in runtime, but got ${$('#cf').text()}` - ); + expect($('#hasRuntime').text()).to.equal('true'); expect($('#hasCache').text()).to.equal('true'); }); }); diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro index c9e67bb05..6ba48e803 100644 --- a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro @@ -8,7 +8,7 @@ const runtime = getRuntime(Astro.request);

Testing

-
{JSON.stringify(runtime.cf)}
+
{!!runtime.cf?.colo}
{!!runtime.caches}
diff --git a/packages/integrations/cloudflare/test/fixtures/runtime/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/runtime/src/pages/index.astro index 320e8e162..aa73ab8ea 100644 --- a/packages/integrations/cloudflare/test/fixtures/runtime/src/pages/index.astro +++ b/packages/integrations/cloudflare/test/fixtures/runtime/src/pages/index.astro @@ -8,8 +8,8 @@ const env = runtime.env;

Testing

-
{JSON.stringify(runtime.cf)}
{JSON.stringify(env)}
+
{!!runtime.cf?.colo}
{!!runtime.caches}
diff --git a/packages/integrations/cloudflare/test/runtime.test.js b/packages/integrations/cloudflare/test/runtime.test.js index 17d813448..be14718e8 100644 --- a/packages/integrations/cloudflare/test/runtime.test.js +++ b/packages/integrations/cloudflare/test/runtime.test.js @@ -30,9 +30,9 @@ describe('Runtime Locals', () => { expect(res.status).to.equal(200); let html = await res.text(); let $ = cheerio.load(html); - expect($('#cf').text()).to.contain('city'); expect($('#env').text()).to.contain('SECRET_STUFF'); expect($('#env').text()).to.contain('secret'); + expect($('#hasRuntime').text()).to.contain('true'); expect($('#hasCache').text()).to.equal('true'); }); }); diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js index 61067c538..36515f831 100644 --- a/packages/integrations/cloudflare/test/test-utils.js +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -48,7 +48,7 @@ export async function runCLI(basePath, { silent, port }) { p.stderr.setEncoding('utf-8'); p.stdout.setEncoding('utf-8'); - const timeout = 10_000; + const timeout = 20_000; const ready = new Promise(async (resolve, reject) => { const failed = setTimeout(() => {