({
fixtureName,
schemaPathFromArgs,
schemaPathFromConfig,
}: {
fixtureName: string
schemaPathFromArgs?: string
schemaPathFromConfig?: string
})
| 21 | } |
| 22 | |
| 23 | async function testSchemaPath({ |
| 24 | fixtureName, |
| 25 | schemaPathFromArgs, |
| 26 | schemaPathFromConfig, |
| 27 | }: { |
| 28 | fixtureName: string |
| 29 | schemaPathFromArgs?: string |
| 30 | schemaPathFromConfig?: string |
| 31 | }) { |
| 32 | const cwd = path.resolve(FIXTURE_CWD, fixtureName) |
| 33 | |
| 34 | let asyncResult: string | null | Error |
| 35 | |
| 36 | try { |
| 37 | const schemaPath = createSchemaPathInput({ schemaPathFromArgs, schemaPathFromConfig, baseDir: cwd }) |
| 38 | asyncResult = (await getSchemaWithPath({ schemaPath, cwd }))?.schemaPath ?? null |
| 39 | } catch (e) { |
| 40 | asyncResult = e as Error |
| 41 | } |
| 42 | |
| 43 | if (typeof asyncResult === 'string') { |
| 44 | asyncResult = stripVTControlCharacters(toUnixPath(path.relative('.', asyncResult))) |
| 45 | } |
| 46 | |
| 47 | if (asyncResult instanceof Error) { |
| 48 | asyncResult.message = stripVTControlCharacters(toUnixPath(asyncResult.message.replace(__dirname, '.'))) |
| 49 | } |
| 50 | |
| 51 | return asyncResult |
| 52 | } |
| 53 | |
| 54 | it('throws error if schema is not found', async () => { |
| 55 | const res = await testSchemaPath({ fixtureName: 'no-schema' }) |
no test coverage detected