From 55e90b70522ceb7c2e14c8e637f499de6434bda6 Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Thu, 29 Sep 2022 11:29:05 -0500 Subject: [PATCH] adding basic test coverage for cached images --- packages/integrations/image/test/image-ssg.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/integrations/image/test/image-ssg.test.js b/packages/integrations/image/test/image-ssg.test.js index 85c25a37a95b..46416f87495b 100644 --- a/packages/integrations/image/test/image-ssg.test.js +++ b/packages/integrations/image/test/image-ssg.test.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import * as cheerio from 'cheerio'; import sizeOf from 'image-size'; +import fs from 'fs/promises'; import { fileURLToPath } from 'url'; import { loadFixture } from './test-utils.js'; @@ -253,7 +254,7 @@ describe('SSG images - build', function () { size: { width: 544, height: 184, type: 'jpg' }, }, ].forEach(({ title, id, regex, size }) => { - it(title, () => { + it(title, async () => { const image = $(id); expect(image.attr('src')).to.match(regex); @@ -261,6 +262,9 @@ describe('SSG images - build', function () { expect(image.attr('height')).to.equal(size.height.toString()); verifyImage(image.attr('src'), size); + + const url = new URL('./fixtures/basic-image/node_modules/.astro/image' + image.attr('src'), import.meta.url); + expect(await fs.stat(url), 'transformed image was cached').to.not.be.undefined; }); }); });