Home / File/ image.test.js — astro Source File

image.test.js — astro Source File

Architecture documentation for image.test.js, a javascript file in the astro codebase. 9 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  27eedb97_fe65_a5ff_3646_65231ad39efe["image.test.js"]
  760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc
  ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> ff334e41_2760_839e_fc38_ab9318c18dfc
  0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> 0b7a6b11_e910_da4b_c617_1880167f44ef
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> 5d6d1861_a18d_b246_cd94_08889ab7e74c
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  ee37b79a_088f_4223_a87f_49622f031a4c["inferRemoteSize.js"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> ee37b79a_088f_4223_a87f_49622f031a4c
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> deb87372_5629_35f8_9a54_e755a08f776a
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  27eedb97_fe65_a5ff_3646_65231ad39efe --> d9a92db9_c95e_9165_13ac_24b3d859d946
  style 27eedb97_fe65_a5ff_3646_65231ad39efe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { cp, rm } from 'node:fs/promises';
import { after, before, describe, it } from 'node:test';
import { inferRemoteSize } from 'astro/assets/utils/inferRemoteSize.js';
import * as cheerio from 'cheerio';
import nodejs from '../dist/index.js';
import { loadFixture } from './test-utils.js';
import { fileURLToPath } from 'node:url';

describe('Image endpoint', () => {
	/** @type {import('./test-utils').Fixture} */
	let fixture;
	let devPreview;

	before(async () => {
		const root = new URL('./fixtures/image/', import.meta.url);
		fixture = await loadFixture({
			root,
			outDir: fileURLToPath(new URL('./dist/image/', root)),
			output: 'server',
			adapter: nodejs({ mode: 'standalone' }),
			image: {
				domains: ['images.unsplash.com'],
			},
		});
		await fixture.build();
		devPreview = await fixture.preview();
	});

	after(async () => {
		await devPreview.stop();
	});

	it('it returns local images', async () => {
		const res = await fixture.fetch('/');
		assert.equal(res.status, 200);
		const html = await res.text();
		const $ = cheerio.load(html);

		const img = $('img[alt=Penguins]').attr('src');
		const host = fixture.config.server.host || 'localhost';
		const port = fixture.config.server.port;
		const size = await inferRemoteSize(`http://${host}:${port}${img}`);
		assert.equal(size.format, 'webp');
		assert.equal(size.width, 50);
		assert.equal(size.height, 33);
	});

	it('it returns remote images', async () => {
		const res = await fixture.fetch('/');
		assert.equal(res.status, 200);
		const html = await res.text();
		const $ = cheerio.load(html);
		const img = $('img[alt=Cornwall]').attr('src');
		const host = fixture.config.server.host || 'localhost';
		const port = fixture.config.server.port;
		const size = await inferRemoteSize(`http://${host}:${port}${img}`);
		assert.equal(size.format, 'webp');
		assert.equal(size.width, 400);
		assert.equal(size.height, 300);
// ... (63 more lines)

Domain

Dependencies

Frequently Asked Questions

What does image.test.js do?
image.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does image.test.js depend on?
image.test.js imports 9 module(s): ../dist/index.js, cheerio, inferRemoteSize.js, loadFixture, node:test, node:url, promises, strict, and 1 more.
Where is image.test.js in the architecture?
image.test.js is located at packages/integrations/node/test/image.test.js (domain: CoreAstro, directory: packages/integrations/node/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free