Home / File/ astro-response.test.js — astro Source File

astro-response.test.js — astro Source File

Architecture documentation for astro-response.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  a0105335_fe82_c63a_ef72_6507741f4749["astro-response.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  a0105335_fe82_c63a_ef72_6507741f4749 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  a0105335_fe82_c63a_ef72_6507741f4749 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  a0105335_fe82_c63a_ef72_6507741f4749 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  a0105335_fe82_c63a_ef72_6507741f4749 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style a0105335_fe82_c63a_ef72_6507741f4749 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @ts-check
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { loadFixture } from './test-utils.js';

// Asset bundling
describe('Returning responses', () => {
	/** @type {Awaited<ReturnType<typeof loadFixture>>} */
	let fixture;
	/** @type {import('./test-utils').DevServer} */
	let devServer;

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/astro-response/',
		});

		devServer = await fixture.startDevServer();
	});

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

	it('Works from a page', async () => {
		const response = await fixture.fetch('/not-found');
		assert.equal(response.status, 404);
	});

	it('Returns the default 404 is body is null', async () => {
		const response = await fixture.fetch('/not-found');
		const html = await response.text();

		assert.equal(response.status, 404);
		assert.equal(html.includes('<pre>Path: /not-found</pre>'), true);
	});

	it('Returns the page is body is not null', async () => {
		const response = await fixture.fetch('/not-found-custom');
		const html = await response.text();

		assert.equal(response.status, 404);
		assert.equal(html.includes('Custom 404'), true);
	});
});

Dependencies

Frequently Asked Questions

What does astro-response.test.js do?
astro-response.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does astro-response.test.js depend on?
astro-response.test.js imports 4 module(s): loadFixture, node:test, strict, test-utils.js.
Where is astro-response.test.js in the architecture?
astro-response.test.js is located at packages/astro/test/astro-response.test.js (domain: IntegrationAdapters, directory: packages/astro/test).

Analyze Your Own Codebase

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

Try Supermodel Free