Is there a way to "unit test" a quarto project? #12313
-
DescriptionPerhaps my question isn't very clear, but I'd like to be able to check that my quarto project isn't broken in the same way that we do unit tests in any software project. For example, I'd like to test that the Are there any tools built into the CLI? Or extensions that cover this specific topic? I couldn't find any resources after browsing Google. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 18 replies
-
Quarto includes a validator, so it won't render unless it considers the YAML valid (for its own notion of valid, of course. It won't be able to catch, eg, typos in author names). If you want to run these yourself, a good way to do it is to add a pre-render script to your quarto project: https://quarto.org/docs/projects/scripts.html#pre-and-post-render. You can also leverage |
Beta Was this translation helpful? Give feedback.
-
In relation to this, I'm wondering whether it's possible to supply front-matter values from the CLI? That way, especially for template testing, it would be much easier to test each parameter (whether it's missing, correct type, etc.). To me it seems the alternative is to create a bunch of files and run them which seems like a lot more overhead. |
Beta Was this translation helpful? Give feedback.
Quarto includes a validator, so it won't render unless it considers the YAML valid (for its own notion of valid, of course. It won't be able to catch, eg, typos in author names).
If you want to run these yourself, a good way to do it is to add a pre-render script to your quarto project: https://quarto.org/docs/projects/scripts.html#pre-and-post-render. You can also leverage
quarto run
and a Makefile if you don't want the tests to be run at every render. Finally, you might want to runquarto inspect
in your projec…