echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

[mini.test] some way to update screenshots #908

Closed MagicDuck closed 1 month ago

MagicDuck commented 1 month ago

Contributing guidelines

Module(s)

mini.test

Description

At the moment, updating screenshots is somewhat painful. My workaround is to add the following to my Makefile:

update-screenshots:
    rm -rf tests/screenshots/* 
    make test

Maybe one way would be to set some env var that expect.reference_screenshot() checks and would force re-write if true? So you would call it like:

make test-file test/test_something.lua UPDATE_SCREENSHOTS=true
echasnovski commented 1 month ago

Thanks for the suggestion (and actually writing tests for the plugin)!

There is a force option in expect.reference_screenshot which you can utilize in helper. I use this one and usually manually set { force = true }, but you can set its default to use UPDATE_SCREENSHOTS environment variable.

All in all, I think this one is in a territory of taste and adaptability to specific plugin needs. So closing as not planned.