Skip to content

Unified throws an error when a file "fails"; how to test this (or disable the behaviour during testing) ? #259

Answered by wooorm
matfire asked this question in Q&A
Discussion options

You must be logged in to vote

Your question has to do with Vite and how it deals with errors and how to use this chaining API.

I really strongly dislike chaining APIs such as this, because it makes everything so darn hard; so I don’t use it; so I am not an expert.

I like straight asserts:

const file = await readFile('./tests/files/schemas.md', 'utf-8')
const processor = unified()
  .use(remarkParse)
  .use(remarkDirective)
  .use(remarkDirectiveToCustomTag, {
    associations: [
      {
        type: 'leafDirective',
        directiveName: 'test',
        tagName: 'test',
        validator: type({
          name: 'string',
          surname: 'string'
        })
      }
    ]
  })
  .use(remarkRehype)
  .use(rehypeStri…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@matfire
Comment options

@wooorm
Comment options

Answer selected by matfire
@matfire
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants