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

controller.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  398fc4ae_8b98_4845_eb90_d5eec2bc0c09["controller.test.js"]
  fa9f5eb3_b4ac_bf78_f51c_c5ee8d8b0c82["../../../dist/core/module-loader/index.js"]
  398fc4ae_8b98_4845_eb90_d5eec2bc0c09 --> fa9f5eb3_b4ac_bf78_f51c_c5ee8d8b0c82
  6b773769_21da_af7b_bf7a_a674250adeab["../../../dist/vite-plugin-astro-server/index.js"]
  398fc4ae_8b98_4845_eb90_d5eec2bc0c09 --> 6b773769_21da_af7b_bf7a_a674250adeab
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  398fc4ae_8b98_4845_eb90_d5eec2bc0c09 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  398fc4ae_8b98_4845_eb90_d5eec2bc0c09 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 398fc4ae_8b98_4845_eb90_d5eec2bc0c09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { createLoader } from '../../../dist/core/module-loader/index.js';
import {
	createController,
	runWithErrorHandling,
} from '../../../dist/vite-plugin-astro-server/index.js';

describe('vite-plugin-astro-server', () => {
	describe('controller', () => {
		it('calls the onError method when an error occurs in the handler', async () => {
			const controller = createController({ loader: createLoader() });
			let error = undefined;
			await runWithErrorHandling({
				controller,
				pathname: '/',
				run() {
					throw new Error('oh no');
				},
				onError(err) {
					error = err;
				},
			});
			assert.equal(typeof error !== 'undefined', true);
			assert.equal(error instanceof Error, true);
		});

		it('sets the state to error when an error occurs in the handler', async () => {
			const controller = createController({ loader: createLoader() });
			await runWithErrorHandling({
				controller,
				pathname: '/',
				run() {
					throw new Error('oh no');
				},
				onError() {},
			});
			assert.equal(controller.state.state, 'error');
		});

		it('calls reload when a file change occurs when in an error state', async () => {
			let reloads = 0;
			const loader = createLoader({
				eachModule() {},
				clientReload() {
					reloads++;
				},
			});
			const controller = createController({ loader });
			loader.events.emit('file-change');
			assert.equal(reloads, 0);
			await runWithErrorHandling({
				controller,
				pathname: '/',
				run() {
					throw new Error('oh no');
				},
				onError() {},
			});
			assert.equal(reloads, 0);
// ... (76 more lines)

Dependencies

  • ../../../dist/core/module-loader/index.js
  • ../../../dist/vite-plugin-astro-server/index.js
  • node:test
  • strict

Frequently Asked Questions

What does controller.test.js do?
controller.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does controller.test.js depend on?
controller.test.js imports 4 module(s): ../../../dist/core/module-loader/index.js, ../../../dist/vite-plugin-astro-server/index.js, node:test, strict.
Where is controller.test.js in the architecture?
controller.test.js is located at packages/astro/test/units/vite-plugin-astro-server/controller.test.js (domain: IntegrationAdapters, directory: packages/astro/test/units/vite-plugin-astro-server).

Analyze Your Own Codebase

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

Try Supermodel Free