core-image-fs-config.test.js — astro Source File
Architecture documentation for core-image-fs-config.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR a7a46342_7e1c_3018_0697_337d89ea7387["core-image-fs-config.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] a7a46342_7e1c_3018_0697_337d89ea7387 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] a7a46342_7e1c_3018_0697_337d89ea7387 --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] a7a46342_7e1c_3018_0697_337d89ea7387 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] a7a46342_7e1c_3018_0697_337d89ea7387 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] a7a46342_7e1c_3018_0697_337d89ea7387 --> d9a92db9_c95e_9165_13ac_24b3d859d946 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] a7a46342_7e1c_3018_0697_337d89ea7387 --> deb87372_5629_35f8_9a54_e755a08f776a style a7a46342_7e1c_3018_0697_337d89ea7387 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 { fileURLToPath } from 'node:url';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe('Image optimization with Vite fs config', () => {
describe('fs.allow and fs.deny', () => {
let fixture;
let devServer;
before(async () => {
fixture = await loadFixture({
root: './fixtures/core-image-fs-config/',
vite: {
server: {
fs: {
allow: [
fileURLToPath(new URL('./fixtures/core-image-fs-config/outside', import.meta.url)),
],
deny: [
fileURLToPath(
new URL('./fixtures/core-image-fs-config-outside-denied', import.meta.url),
),
],
},
},
},
});
devServer = await fixture.startDevServer();
});
after(async () => {
await devServer.stop();
});
it('allows loading images from directories in fs.allow via /_image endpoint', async () => {
// Get the absolute path to the allowed image
const outsidePath = fileURLToPath(
new URL('./fixtures/core-image-fs-config/outside/penguin-outside.jpg', import.meta.url),
);
const fsUrl = '/@fs/' + outsidePath.replace(/\\/g, '/');
// Try to load the image via the /_image endpoint
const imageUrl = `/_image?href=${encodeURIComponent(fsUrl)}&f=webp&w=300&h=200`;
const response = await fixture.fetch(imageUrl);
assert.equal(response.status, 200, 'Should successfully load image from fs.allow directory');
assert.equal(response.headers.get('content-type'), 'image/webp', 'Should return webp format');
});
it('denies loading images from directories in fs.deny via /_image endpoint', async () => {
// Get the absolute path to the denied image
const deniedPath = fileURLToPath(
new URL(
'./fixtures/core-image-fs-config-outside-denied/penguin-denied.jpg',
import.meta.url,
),
);
const fsUrl = '/@fs/' + deniedPath.replace(/\\/g, '/');
// ... (64 more lines)
Domain
Dependencies
- cheerio
- loadFixture
- node:test
- node:url
- strict
- test-utils.js
Source
Frequently Asked Questions
What does core-image-fs-config.test.js do?
core-image-fs-config.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does core-image-fs-config.test.js depend on?
core-image-fs-config.test.js imports 6 module(s): cheerio, loadFixture, node:test, node:url, strict, test-utils.js.
Where is core-image-fs-config.test.js in the architecture?
core-image-fs-config.test.js is located at packages/astro/test/core-image-fs-config.test.js (domain: IntegrationAdapters, directory: packages/astro/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free