I need to test my web app in a scenario where there’s no disk space remaining, i.e. I cannot write any more files. But I don’t want to fill my hard drive with junk just to make
Create a disk/filesystem image in a regular file (of limited size) and loop mount it.
But if you'll be doing this often I'd create a virtual machine—you'll find opportunity to reuse it.