tingerrr / typst-test Goto Github PK
View Code? Open in Web Editor NEWA visual regression test runner for typst packages.
License: MIT License
A visual regression test runner for typst packages.
License: MIT License
I propose changing the folder structure, such that each test file lives in its own folder. A test folder contains a Typst file (e.g. "test.typ") plus the reference image.
CeTZ currently uses its own test script, which structures the tests as given above, but we would like to use typst-test
.
CeTZ's tests are recognized by recursively scanning the tests/
directory for test.typ
files and, if found, use the folder of those files as test-cases. This allows nesting/grouping tests by topic by just putting them in common parent directories.
By adding typst as a dependency, test output generation and comparison could be done entirely in memory. This seems like a sensible thing to do, here are some of the pros and cons:
Pros
Cons
When generating a diff image, the following things could be improved:
Currently whenever a new test is created it is populated with "Hello World!". I then have to copy and paste in the package's import statement and other setup which is common to all tests I want to run.
I would like a way to change the default test on a per project basis.
The current implementation is a little brittle, this has a lot of downsides:
?
, other times it's swallowed and simply printed to stdoutThe core should be reworked into a solid foundation on which new features can be built. At this stage, the project is still fairly small, and a rewrite is feasible.
I want to achieve the following goals with the rewrite:
Built from commit version: ce06d7e
Rust: 1.75.0
Platform: Windows 11 Home 22H2
Repository: https://github.com/fenjalien/metro/
Running typst-test run
works as expected apart from the diff images are not being generated in the diff folders. I've linked the repository I'm having the issue with.
By extracting the core implementation of test scaffolding and test running, other projects such as typst-lsp and typst-preview could benefit from it without needing to interface with the bare bones binary interface.
Typst-preview already supports a special presentation mode for polylux, it's not too far-fetched to assume they could be interested in a special test-watching mode. Likewise, typst-lsp could allow discovering and running tests easily.
This is blocked by #12.
With a folder structure like test/higher/lower/test.typ
and no test.typ
in higher/
. Using the add
command removes everything in higher/
.
Allow users to run custom actions between test stages.
On compelling use case for this is being able to test typstfmt (see #3). This avoids pulling it in as a dependency or even tying it to a command line option of typst-test at all.
With sufficiently flexible custom actions, typstfmt could generate the references from the unaltered test script and the output from the altered version, failing if the formatting introduce a visual regression.
Looks really nice!
Maybe it could be use to test formatters as well!
Given a formatter and a test file
It could happily live next to typstfmt when I get up to it but I think it might be better suited in typst-test
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.