restart.test.js — astro Source File
Architecture documentation for restart.test.js, a javascript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 24aa55df_d7c8_ad4c_9bf7_2f28db824daa["restart.test.js"] d2bfa879_b069_eef7_1966_7ccf5be8e2fd["../../../dist/core/dev/index.js"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> d2bfa879_b069_eef7_1966_7ccf5be8e2fd b0be4d0c_86b6_a283_f2af_003189bfd572["test-utils.js"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> b0be4d0c_86b6_a283_f2af_003189bfd572 f0937d94_cf30_e0fa_fbd5_135f8c876f70["createFixture"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> f0937d94_cf30_e0fa_fbd5_135f8c876f70 37bee138_718e_22c5_b294_37b0235244a2["createRequestAndResponse"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> 37bee138_718e_22c5_b294_37b0235244a2 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> 6b0635f9_51ea_77aa_767b_7857878e98a6 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] 24aa55df_d7c8_ad4c_9bf7_2f28db824daa --> deb87372_5629_35f8_9a54_e755a08f776a style 24aa55df_d7c8_ad4c_9bf7_2f28db824daa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import {
createContainerWithAutomaticRestart,
startContainer,
} from '../../../dist/core/dev/index.js';
import { createFixture, createRequestAndResponse } from '../test-utils.js';
/** @type {import('astro').AstroInlineConfig} */
const defaultInlineConfig = {
logLevel: 'silent',
};
function isStarted(container) {
return !!container.viteServer.httpServer?.listening;
}
// Checking for restarts may hang if no restarts happen, so set a 20s timeout for each test
describe('dev container restarts', { timeout: 20000 }, () => {
it('Surfaces config errors on restarts', async () => {
const fixture = await createFixture({
'/src/pages/index.astro': `
<html>
<head><title>Test</title></head>
<body>
<h1>Test</h1>
</body>
</html>
`,
'/astro.config.mjs': ``,
});
const restart = await createContainerWithAutomaticRestart({
inlineConfig: {
...defaultInlineConfig,
root: fixture.path,
},
});
try {
let r = createRequestAndResponse({
method: 'GET',
url: '/',
});
restart.container.handle(r.req, r.res);
let html = await r.text();
const $ = cheerio.load(html);
assert.equal(r.res.statusCode, 200);
assert.equal($('h1').length, 1);
// Create an error
let restartComplete = restart.restarted();
await fixture.writeFile('/astro.config.mjs', 'const foo = bar');
// TODO: fix this hack
restart.container.viteServer.watcher.emit(
'change',
fixture.getPath('/astro.config.mjs').replace(/\\/g, '/'),
);
// ... (174 more lines)
Domain
Subdomains
Functions
Dependencies
- ../../../dist/core/dev/index.js
- cheerio
- createFixture
- createRequestAndResponse
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does restart.test.js do?
restart.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in restart.test.js?
restart.test.js defines 1 function(s): isStarted.
What does restart.test.js depend on?
restart.test.js imports 7 module(s): ../../../dist/core/dev/index.js, cheerio, createFixture, createRequestAndResponse, node:test, strict, test-utils.js.
Where is restart.test.js in the architecture?
restart.test.js is located at packages/astro/test/units/dev/restart.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/units/dev).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free