Skip to content

Commit e7e4a3a

Browse files
committed
Log when writing a non-existent expected file
1 parent 15040d0 commit e7e4a3a

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/fixtures-directory.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ async function getOptions(directory: URL): Promise<unknown> {
138138
return {}
139139
}
140140

141+
/**
142+
* Write content to a file.
143+
*
144+
* @param url
145+
* The file URL to write to.
146+
* @param content
147+
* The content to write to the file.
148+
*/
149+
async function outputFile(url: URL, content: string): Promise<undefined> {
150+
// eslint-disable-next-line no-console
151+
console.log('Writing', makePrettyPath(url))
152+
await writeFile(url, content)
153+
}
154+
141155
/**
142156
* Create a test for a single test fixture directory.
143157
*
@@ -161,8 +175,8 @@ export function createTest<T>(
161175
write: boolean | undefined,
162176
format: boolean | undefined,
163177
spec: Test<T>
164-
): () => Promise<void> {
165-
return async function run(): Promise<void> {
178+
): () => Promise<undefined> {
179+
return async function run(): Promise<undefined> {
166180
let generate: Generate<T>
167181
let inputUrl: URL
168182
let expectedUrl: URL
@@ -210,7 +224,7 @@ export function createTest<T>(
210224
// This is only covered in CI.
211225
/* c8 ignore start */
212226
if (expected == null) {
213-
return writeFile(expectedUrl, actual)
227+
return outputFile(expectedUrl, actual)
214228
}
215229

216230
/* c8 ignore stop */
@@ -221,9 +235,7 @@ export function createTest<T>(
221235
// This is only covered outside of CI.
222236
/* c8 ignore start */
223237
if (write && error instanceof AssertionError) {
224-
// eslint-disable-next-line no-console
225-
console.log('Writing', makePrettyPath(expectedUrl))
226-
await writeFile(expectedUrl, actual)
238+
await outputFile(expectedUrl, actual)
227239
}
228240

229241
/* c8 ignore stop */

0 commit comments

Comments
 (0)