Home / File/ server-entry.test.js — astro Source File

server-entry.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  4558c373_16ad_728b_c121_0f97031cad5d["server-entry.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  4558c373_16ad_728b_c121_0f97031cad5d --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  4558c373_16ad_728b_c121_0f97031cad5d --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  be670a78_841c_46e5_0af5_c5c328869ecb["test-adapter.js"]
  4558c373_16ad_728b_c121_0f97031cad5d --> be670a78_841c_46e5_0af5_c5c328869ecb
  a1be80d1_ad15_0c46_251c_6b2350548320["index.js"]
  4558c373_16ad_728b_c121_0f97031cad5d --> a1be80d1_ad15_0c46_251c_6b2350548320
  1f5eb951_aa74_e237_1cb7_97cb45df3a7b["fakeAdapter"]
  4558c373_16ad_728b_c121_0f97031cad5d --> 1f5eb951_aa74_e237_1cb7_97cb45df3a7b
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  4558c373_16ad_728b_c121_0f97031cad5d --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  4558c373_16ad_728b_c121_0f97031cad5d --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  4558c373_16ad_728b_c121_0f97031cad5d --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  4558c373_16ad_728b_c121_0f97031cad5d --> d9a92db9_c95e_9165_13ac_24b3d859d946
  style 4558c373_16ad_728b_c121_0f97031cad5d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, it } from 'node:test';
import { loadFixture } from './test-utils.js';
import testAdapter, { selfTestAdapter } from './test-adapter.js';
import assert from 'node:assert/strict';
import fakeAdapter from './fixtures/server-entry/fake-adapter/index.js';
import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';

describe('Server entry', () => {
	/** @type {import('./test-utils').Fixture} */
	let fixture;
	let app;

	it('should load the custom entry when using legacy entrypoint', async () => {
		fixture = await loadFixture({
			root: './fixtures/server-entry',
			output: 'server',
			adapter: testAdapter(),
			build: {
				serverEntry: 'custom.mjs',
			},
		});

		await fixture.build();
		app = await fixture.loadTestAdapterApp(false, 'custom.mjs');

		const request = new Request('http://example.com/');
		const response = await app.render(request);
		assert.equal(response.status, 200);
	});

	it('should load the custom entry when using self entrypoint', async () => {
		fixture = await loadFixture({
			root: './fixtures/server-entry',
			output: 'server',
			adapter: selfTestAdapter(),
			build: {
				serverEntry: 'custom.mjs',
			},
		});

		await fixture.build();
		app = await fixture.loadSelfAdapterApp(false, 'custom.mjs');

		const request = new Request('http://example.com/');
		const response = await app.render(request);
		assert.equal(response.status, 200);
	});

	it('should load the custom entry when using package export (string) as self entrypoint', async () => {
		fixture = await loadFixture({
			root: './fixtures/server-entry',
			output: 'server',
			adapter: fakeAdapter({ shape: 'string' }),
			build: {
				serverEntry: 'custom.mjs',
			},
		});

		await fixture.build();

		assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir))));
	});

	it('should load the custom entry when using package export (object) as self entrypoint', async () => {
		fixture = await loadFixture({
			root: './fixtures/server-entry',
			output: 'server',
			adapter: fakeAdapter({ shape: 'object' }),
			build: {
				serverEntry: 'custom.mjs',
			},
		});

		await fixture.build();

		assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir))));
	});

	it('should load the custom entry when using package export (array) as self entrypoint', async () => {
		fixture = await loadFixture({
			root: './fixtures/server-entry',
			output: 'server',
			adapter: fakeAdapter({ shape: 'array' }),
			build: {
				serverEntry: 'custom.mjs',
			},
		});

		await fixture.build();

		assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir))));
	});
});

Dependencies

Frequently Asked Questions

What does server-entry.test.js do?
server-entry.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does server-entry.test.js depend on?
server-entry.test.js imports 9 module(s): fakeAdapter, index.js, loadFixture, node:fs, node:test, node:url, strict, test-adapter.js, and 1 more.
Where is server-entry.test.js in the architecture?
server-entry.test.js is located at packages/astro/test/server-entry.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