Skip to content

Commit

Permalink
Add assertion about missing fixture file
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jul 15, 2023
1 parent 72154cb commit 9f5046b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type Options, execa } from 'execa';
import fse from 'fs-extra';
import assert from 'node:assert';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
Expand All @@ -26,6 +27,14 @@ export async function fixture(
) {
let scenario = options?.scenario ?? 'default';
let fixtureFilePath = path.isAbsolute(file) ? file : path.join(fixturesPath, scenario, file);

let exists = await fse.pathExists(fixtureFilePath);

assert(
exists,
`Fixture file ${fixtureFilePath} does not exist. To make this work, place a new file ${fixtureFilePath} in the tests/fixtures/${scenario} directory`
);

let contents = await fs.readFile(fixtureFilePath);

return contents.toString();
Expand Down

0 comments on commit 9f5046b

Please sign in to comment.