createFixture() — astro Function Reference
Architecture documentation for the createFixture() function in astro-sync.test.js from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b986d062_9e9a_0abf_b359_867ad0f09623["createFixture()"] 9d62e497_e521_a9db_9c44_090a22bbaea7["astro-sync.test.js"] b986d062_9e9a_0abf_b359_867ad0f09623 -->|defined in| 9d62e497_e521_a9db_9c44_090a22bbaea7 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture()"] b986d062_9e9a_0abf_b359_867ad0f09623 -->|calls| dd4f09ce_3fd7_8295_f616_8876cda4555c style b986d062_9e9a_0abf_b359_867ad0f09623 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/test/astro-sync.test.js lines 10–129
const createFixture = () => {
/** @type {Awaited<ReturnType<typeof loadFixture>>} */
let astroFixture;
/** @type {Record<string, string>} */
const writtenFiles = {};
/** @type {Array<string>} */
const warnLogs = [];
/**
* @param {string} path
*/
const getExpectedPath = (path) => fileURLToPath(new URL(path, astroFixture.config.root));
return {
/** @param {string} root */
async load(root) {
astroFixture = await loadFixture({ root });
return astroFixture.config;
},
clean() {
fs.rmSync(new URL('./.astro/', astroFixture.config.root), { force: true, recursive: true });
},
async whenSyncing() {
const fsMock = {
...fs,
/**
* @param {fs.PathLike} path
* @param {string} contents
*/
writeFileSync(path, contents) {
writtenFiles[path.toString()] = contents;
return fs.writeFileSync(path, contents);
},
promises: {
...fs.promises,
/**
* @param {fs.PathLike} path
* @param {string} contents
*/
writeFile(path, contents) {
writtenFiles[path.toString()] = contents;
return fs.promises.writeFile(path, contents);
},
},
};
const originalWarn = console.warn;
console.warn = (message) => {
originalWarn(message);
warnLogs.push(message);
};
try {
await astroFixture.sync(
{ root: fileURLToPath(astroFixture.config.root) },
{
// @ts-ignore
fs: fsMock,
},
);
} finally {
console.error = originalWarn;
}
},
/** @param {string} path */
thenFileShouldExist(path) {
assert.equal(
writtenFiles.hasOwnProperty(getExpectedPath(path)),
true,
`${path} does not exist`,
);
},
/**
* @param {string} path
* @param {string} content
* @param {string | undefined} error
*/
thenFileContentShouldInclude(path, content, error = undefined) {
assert.equal(writtenFiles[getExpectedPath(path)].includes(content), true, error);
},
/**
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does createFixture() do?
createFixture() is a function in the astro codebase, defined in packages/astro/test/astro-sync.test.js.
Where is createFixture() defined?
createFixture() is defined in packages/astro/test/astro-sync.test.js at line 10.
What does createFixture() call?
createFixture() calls 1 function(s): loadFixture.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free