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

errors.test.js — astro Source File

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

import 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';

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

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/errors/',
			output: 'server',
			adapter: nodejs({ mode: 'standalone' }),
		});
		await fixture.build();
	});
	let devPreview;

	// The two tests that need the server to run are skipped
	// before(async () => {
	//    devPreview = await fixture.preview();
	// });
	after(async () => {
		await devPreview?.stop();
	});

	it(
		'rejected promise in template',
		{ skip: true, todo: 'Review the response from the in-stream' },
		async () => {
			const res = await fixture.fetch('/in-stream');
			const html = await res.text();
			const $ = cheerio.load(html);

			assert.equal($('p').text().trim(), 'Internal server error');
		},
	);

	it(
		'generator that throws called in template',
		{ skip: true, todo: 'Review the response from the generator' },
		async () => {
			const result = ['<!DOCTYPE html><h1>Astro</h1> 1', 'Internal server error'];

			/** @type {Response} */
			const res = await fixture.fetch('/generator');
			const reader = res.body.getReader();
			const decoder = new TextDecoder();
			const chunk1 = await reader.read();
			const chunk2 = await reader.read();
			const chunk3 = await reader.read();
			assert.equal(chunk1.done, false);
			if (chunk2.done) {
				assert.equal(decoder.decode(chunk1.value), result.join(''));
			} else if (chunk3.done) {
				assert.equal(decoder.decode(chunk1.value), result[0]);
				assert.equal(decoder.decode(chunk2.value), result[1]);
			} else {
				throw new Error('The response should take at most 2 chunks.');
			}
		},
	);
});

Domain

Dependencies

Frequently Asked Questions

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