Skip to content

Commit

Permalink
Rename fixture to readFixture and add a comment block describe how th…
Browse files Browse the repository at this point in the history
…e fixtures / scenarios work
  • Loading branch information
NullVoxPopuli committed Jul 16, 2023
1 parent 3852609 commit 6ea52bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import { expect } from 'vitest';

import { fixture, packageJsonAt } from './utils.js';
import { packageJsonAt, readFixture } from './utils.js';

interface AssertGeneratedOptions {
projectRoot: string;
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function matchesFixture(
}

let sourceContents = (await fs.readFile(testFilePath)).toString();
let fixtureContents = await fixture(fixtureFile, { scenario });
let fixtureContents = await readFixture(fixtureFile, { scenario });

/**
* We trim because whether or not the source or fixture has
Expand Down
10 changes: 9 additions & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ const fixturesPath = path.join(__dirname, 'fixtures');

export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'] as const;

export async function fixture(
/**
* Returns the contents of a file from the "tests/fixtures" directory.
* The "tests/fixtures" directory contains sub-directories, "scenarios".
* This is we can have different sets of fixtures, depending on what we're testing.
*
* The default scenario is "default", and represents the the file contents when we provide
* no arguments to the blueprint
*/
export async function readFixture(
/**
* Which file within in the fixture-set / scenario to read
*/
Expand Down

0 comments on commit 6ea52bc

Please sign in to comment.