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

assets.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  88032f43_074b_e17c_21ad_fb8ea851953b["assets.test.js"]
  760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc
  ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> ff334e41_2760_839e_fc38_ab9318c18dfc
  0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> 0b7a6b11_e910_da4b_c617_1880167f44ef
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> deb87372_5629_35f8_9a54_e755a08f776a
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  88032f43_074b_e17c_21ad_fb8ea851953b --> d9a92db9_c95e_9165_13ac_24b3d859d946
  style 88032f43_074b_e17c_21ad_fb8ea851953b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

describe('Assets', () => {
	/** @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/assets/', root)),
			output: 'server',
			adapter: nodejs({ mode: 'standalone' }),
			vite: {
				build: {
					assetsInlineLimit: 0,
				},
			},
		});
		await fixture.build();
		devPreview = await fixture.preview();
	});

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

	it('Assets within the _astro folder should be given immutable headers', async () => {
		let response = await fixture.fetch('/text-file');
		let cacheControl = response.headers.get('cache-control');
		assert.equal(cacheControl, null);
		const html = await response.text();
		const $ = cheerio.load(html);

		// Fetch the asset
		const fileURL = $('a').attr('href');
		response = await fixture.fetch(fileURL);
		cacheControl = response.headers.get('cache-control');
		assert.equal(cacheControl, 'public, max-age=31536000, immutable');
	});
});

Domain

Dependencies

Frequently Asked Questions

What does assets.test.js do?
assets.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does assets.test.js depend on?
assets.test.js imports 7 module(s): ../dist/index.js, cheerio, loadFixture, node:test, node:url, strict, test-utils.js.
Where is assets.test.js in the architecture?
assets.test.js is located at packages/integrations/node/test/assets.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