diff --git a/README.md b/README.md index 33c3c71..02b0064 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,10 @@ return a string that should match the expected output. A second argument `option This may contain the options of the fixture. These options are read from the `options.cjs`, `options.js`, `options.json` or `options.mjs` file in the fixture directory. -A test may be an object with the `generate` and optional `input`, `expected` properties. In this -case `input` determines which input file to read, `generate` serves as the generate function, and -`expected` refers to the expected output file. +A test may be an object with the `generate` and optional `input`, `expected`, and `ignore` +properties. In this case `input` determines which input file to read, `generate` serves as the +generate function, and `expected` refers to the expected output file. If `ignore` is true, the +result is written, but assertion failures are ignored. ## Compatibility diff --git a/src/fixtures-directory.ts b/src/fixtures-directory.ts index 94f2c69..f5e0f3b 100644 --- a/src/fixtures-directory.ts +++ b/src/fixtures-directory.ts @@ -30,6 +30,11 @@ type Generate = ( ) => Buffer | PromiseLike | VFile | string interface FixtureTest { + /** + * If true, assertion failures are ignored. The expected fixture is still written. + */ + ignore?: boolean + /** * The fixture input file name to read. If the input has an extension, it’s treated as an exact * file name. Otherwise, a file is looked up in the fixture directory whose base name matches the @@ -184,6 +189,7 @@ export function createTest( let generate: Generate let inputUrl: URL let expectedUrl: URL + let ignore: boolean | undefined if (typeof spec === 'function') { generate = spec @@ -193,6 +199,7 @@ export function createTest( generate = spec.generate inputUrl = await getInputUrl(dir, spec.input) expectedUrl = new URL(spec.expected ?? name, dir) + ignore = spec.ignore } const fixtureOptions = await getOptions(dir) @@ -244,7 +251,9 @@ export function createTest( /* c8 ignore stop */ - throw error + if (!ignore) { + throw error + } } } }