From 9f5046b39b06af99d47cec0342ea80be8c89ebf7 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 15 Jul 2023 12:16:08 -0400 Subject: [PATCH] Add assertion about missing fixture file --- tests/utils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/utils.ts b/tests/utils.ts index 50ec6093..19c8ab8d 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -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'; @@ -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();