Home / Function/ selfTestAdapter() — astro Function Reference

selfTestAdapter() — astro Function Reference

Architecture documentation for the selfTestAdapter() function in test-adapter.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  923c35bb_2f8d_692b_68c2_0fb168bdbf71["selfTestAdapter()"]
  be670a78_841c_46e5_0af5_c5c328869ecb["test-adapter.js"]
  923c35bb_2f8d_692b_68c2_0fb168bdbf71 -->|defined in| be670a78_841c_46e5_0af5_c5c328869ecb
  style 923c35bb_2f8d_692b_68c2_0fb168bdbf71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/test-adapter.js lines 155–293

export function selfTestAdapter({
	provideAddress = true,
	staticHeaders = false,
	extendAdapter,
	setMiddlewareEntryPoint,
	setManifest,
	setRouteToHeaders,
	env,
} = {}) {
	return {
		name: 'my-ssr-adapter',
		hooks: {
			'astro:config:setup': ({ updateConfig }) => {
				updateConfig({
					vite: {
						build: {
							rollupOptions: {
								input: '@my-ssr',
							},
						},
						plugins: [
							{
								resolveId: {
									filter: {
										id: /^(astro\/app|@my-ssr)$/,
									},
									handler(id) {
										if (id === '@my-ssr') {
											return id;
										}
										return viteID(new URL('../dist/core/app/index.js', import.meta.url));
									},
								},
								load: {
									filter: {
										id: /^@my-ssr$/,
									},
									handler() {
										return {
											code: `
											import { App, AppPipeline } from 'astro/app';
											import {manifest} from "virtual:astro:manifest"
											import fs from 'fs';

											${
												env
													? `
											await import('astro/env/setup')
												.then(mod => mod.setGetEnv((key) => {
													const data = ${JSON.stringify(env)};
													return data[key];
												}))
												.catch(() => {});`
													: ''
											}

											class MyApp extends App {
												#manifest = null;
												constructor(manifest, streaming) {
													super(manifest, streaming);
													this.#manifest = manifest;
												}
												
												createPipeline(streaming) {
													return AppPipeline.create({
														manifest: this.manifest,
														logger: this.logger,
														streaming
													})
												}

												async render(request, { routeData, clientAddress, locals, addCookieHeader, prerenderedErrorPageFetch } = {}) {
													const url = new URL(request.url);
													if(this.#manifest.assets.has(url.pathname)) {
														const filePath = new URL(this.removeBase(url.pathname).replace(/^\\//, ''), this.#manifest.buildClientDir);
														const data = await fs.promises.readFile(filePath);
														return new Response(data);
													}

													return super.render(request, {
														routeData,

Subdomains

Frequently Asked Questions

What does selfTestAdapter() do?
selfTestAdapter() is a function in the astro codebase, defined in packages/astro/test/test-adapter.js.
Where is selfTestAdapter() defined?
selfTestAdapter() is defined in packages/astro/test/test-adapter.js at line 155.

Analyze Your Own Codebase

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

Try Supermodel Free