redirects.test.js — astro Source File
Architecture documentation for redirects.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1a28d397_84ea_4757_5543_7970673c32ca["redirects.test.js"] 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"] 1a28d397_84ea_4757_5543_7970673c32ca --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"] 1a28d397_84ea_4757_5543_7970673c32ca --> ff334e41_2760_839e_fc38_ab9318c18dfc 0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"] 1a28d397_84ea_4757_5543_7970673c32ca --> 0b7a6b11_e910_da4b_c617_1880167f44ef 0f98dbf7_3a77_7344_74c6_cb678c4a98d0["waitServerListen"] 1a28d397_84ea_4757_5543_7970673c32ca --> 0f98dbf7_3a77_7344_74c6_cb678c4a98d0 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 1a28d397_84ea_4757_5543_7970673c32ca --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 1a28d397_84ea_4757_5543_7970673c32ca --> 6b0635f9_51ea_77aa_767b_7857878e98a6 style 1a28d397_84ea_4757_5543_7970673c32ca 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 nodejs from '../dist/index.js';
import { loadFixture, waitServerListen } from './test-utils.js';
describe('Redirects', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
let server;
before(async () => {
fixture = await loadFixture({
root: './fixtures/redirects/',
adapter: nodejs({ mode: 'standalone' }),
});
await fixture.build();
const { startServer } = await fixture.loadAdapterEntryModule();
const res = startServer();
server = res.server;
await waitServerListen(server.server);
});
after(async () => {
await server.stop();
await fixture.clean();
});
function fetchEndpoint(url, options = {}) {
return fetch(`http://${server.host}:${server.port}/${url}`, { ...options, redirect: 'manual' });
}
it('should redirect with default 301 status for simple redirects', async () => {
const response = await fetchEndpoint('old-page');
assert.equal(response.status, 301);
assert.equal(response.headers.get('location'), '/new-page');
});
it('should redirect with custom 301 status', async () => {
const response = await fetchEndpoint('old-page-301');
assert.equal(response.status, 301);
assert.equal(response.headers.get('location'), '/new-page-301');
});
it('should redirect with custom 302 status', async () => {
const response = await fetchEndpoint('old-page-302');
assert.equal(response.status, 302);
assert.equal(response.headers.get('location'), '/new-page-302');
});
it('should handle dynamic redirects with parameters', async () => {
const response = await fetchEndpoint('dynamic/test-slug');
assert.equal(response.status, 301);
assert.equal(response.headers.get('location'), '/pages/test-slug');
});
it('should handle spread redirects with parameters', async () => {
const response = await fetchEndpoint('spread/some/nested/path');
assert.equal(response.status, 301);
assert.equal(response.headers.get('location'), '/content/some/nested/path');
});
it('should redirect to external URL', async () => {
const response = await fetchEndpoint('external');
assert.equal(response.status, 301);
assert.equal(response.headers.get('location'), 'https://example.com/');
});
});
Domain
Dependencies
- ../dist/index.js
- loadFixture
- node:test
- strict
- test-utils.js
- waitServerListen
Source
Frequently Asked Questions
What does redirects.test.js do?
redirects.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does redirects.test.js depend on?
redirects.test.js imports 6 module(s): ../dist/index.js, loadFixture, node:test, strict, test-utils.js, waitServerListen.
Where is redirects.test.js in the architecture?
redirects.test.js is located at packages/integrations/node/test/redirects.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