sessions.test.js — astro Source File
Architecture documentation for sessions.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3a624899_b8a3_94fd_7809_67e5f92b141b["sessions.test.js"] 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> ff334e41_2760_839e_fc38_ab9318c18dfc 0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> 0b7a6b11_e910_da4b_c617_1880167f44ef e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> 6b0635f9_51ea_77aa_767b_7857878e98a6 ca52ff61_c81f_c2ca_81b6_5a678b65fd31["devalue"] 3a624899_b8a3_94fd_7809_67e5f92b141b --> ca52ff61_c81f_c2ca_81b6_5a678b65fd31 style 3a624899_b8a3_94fd_7809_67e5f92b141b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// @ts-check
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import * as devalue from 'devalue';
import nodejs from '../dist/index.js';
import { loadFixture } from './test-utils.js';
describe('Astro.session', () => {
describe('Production', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
/** @type {import('../../../astro/src/types/public/preview.js').PreviewServer} */
let app;
before(async () => {
fixture = await loadFixture({
root: './fixtures/sessions/',
output: 'server',
adapter: nodejs({ mode: 'middleware' }),
});
await fixture.build({});
app = await fixture.preview({});
});
after(async () => {
await app.stop();
});
it('can regenerate session cookies upon request', async () => {
const firstResponse = await fixture.fetch('/regenerate');
// @ts-ignore
const firstHeaders = firstResponse.headers.get('set-cookie').split(',');
const firstSessionId = firstHeaders[0].split(';')[0].split('=')[1];
const secondResponse = await fixture.fetch('/regenerate', {
method: 'GET',
headers: {
cookie: `astro-session=${firstSessionId}`,
},
});
// @ts-ignore
const secondHeaders = secondResponse.headers.get('set-cookie').split(',');
const secondSessionId = secondHeaders[0].split(';')[0].split('=')[1];
assert.notEqual(firstSessionId, secondSessionId);
});
it('can save session data by value', async () => {
const firstResponse = await fixture.fetch('/update');
const firstValue = await firstResponse.json();
assert.equal(firstValue.previousValue, 'none');
// @ts-ignore
const firstHeaders = firstResponse.headers.get('set-cookie').split(',');
const firstSessionId = firstHeaders[0].split(';')[0].split('=')[1];
const secondResponse = await fixture.fetch('/update', {
method: 'GET',
headers: {
cookie: `astro-session=${firstSessionId}`,
},
});
// ... (122 more lines)
Domain
Dependencies
- ../dist/index.js
- devalue
- loadFixture
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does sessions.test.js do?
sessions.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does sessions.test.js depend on?
sessions.test.js imports 6 module(s): ../dist/index.js, devalue, loadFixture, node:test, strict, test-utils.js.
Where is sessions.test.js in the architecture?
sessions.test.js is located at packages/integrations/node/test/sessions.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