Home / File/ routes-json.test.js — astro Source File

routes-json.test.js — astro Source File

Architecture documentation for routes-json.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  0bc1472a_0a28_f928_208f_19e931dbfcdb["routes-json.test.js"]
  c57448e9_39cb_8f2c_813c_f4c854683c87["../dist/index.js"]
  0bc1472a_0a28_f928_208f_19e931dbfcdb --> c57448e9_39cb_8f2c_813c_f4c854683c87
  635e1221_67bb_e784_624a_d6d63643872b["_test-utils.js"]
  0bc1472a_0a28_f928_208f_19e931dbfcdb --> 635e1221_67bb_e784_624a_d6d63643872b
  33b9a01d_12ac_568f_9775_9e80b35139cb["loadFixture"]
  0bc1472a_0a28_f928_208f_19e931dbfcdb --> 33b9a01d_12ac_568f_9775_9e80b35139cb
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  0bc1472a_0a28_f928_208f_19e931dbfcdb --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  0bc1472a_0a28_f928_208f_19e931dbfcdb --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 0bc1472a_0a28_f928_208f_19e931dbfcdb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import cloudflare from '../dist/index.js';
import { loadFixture } from './_test-utils.js';

describe('_routes.json generation', () => {
	describe('of on-demand and prerenderd', () => {
		/** @type {import('../../../astro/test/test-utils').Fixture} */
		let fixture;

		before(async () => {
			fixture = await loadFixture({
				root: new URL('./fixtures/routes-json/', import.meta.url).toString(),
				srcDir: './src/mixed',
				adapter: cloudflare({}),
			});
			await fixture.build();
		});

		it('creates `include` for on-demand and `exclude` for prerenderd', async () => {
			const _routesJson = await fixture.readFile('/_routes.json');
			const routes = JSON.parse(_routesJson);

			assert.deepEqual(routes, {
				version: 1,
				include: ['/_server-islands/*', '/_image', '/a/*'],
				exclude: ['/_astro/*', '/redirectme', '/public.txt', '/a', '/a/redirect', '/404', '/b'],
			});
		});
	});

	describe('of only on-demand', () => {
		let fixture;

		before(async () => {
			fixture = await loadFixture({
				root: new URL('./fixtures/routes-json/', import.meta.url).toString(),
				srcDir: './src/dynamicOnly',
				adapter: cloudflare({}),
			});
			await fixture.build();
		});

		after(async () => {
			await fixture.clean();
		});

		it('creates a wildcard `include` and `exclude` only for static assets and redirects', async () => {
			const _routesJson = await fixture.readFile('/_routes.json');
			const routes = JSON.parse(_routesJson);

			assert.deepEqual(routes, {
				version: 1,
				include: ['/*'],
				exclude: ['/_astro/*', '/redirectme', '/public.txt', '/a/*'],
			});
		});
	});

	describe('of only prerenderd', () => {
// ... (292 more lines)

Domain

Dependencies

Frequently Asked Questions

What does routes-json.test.js do?
routes-json.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does routes-json.test.js depend on?
routes-json.test.js imports 5 module(s): ../dist/index.js, _test-utils.js, loadFixture, node:test, strict.
Where is routes-json.test.js in the architecture?
routes-json.test.js is located at packages/integrations/cloudflare/test/routes-json.test.js (domain: CoreAstro, directory: packages/integrations/cloudflare/test).

Analyze Your Own Codebase

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

Try Supermodel Free