test(images): release the sharp handle before teardown (#301)

libvips caches input file mappings in memory after a pipeline finishes. On Windows, this keeps an open handle on the input file, and the OS refuses to delete a file with an open handle. The animated-WebP test triggers a pipeline rejection (correctly refusing a multi-page rotation), so the mapping stays in cache and afterEach cannot remove the test directory.

Disabling the cache costs these tests nothing: each file is read exactly once during its test, so there is no reuse to cache. With caching disabled, Windows can delete the input files and afterEach succeeds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-04 13:40:18 -05:00
co-authored by Claude Opus 5
parent 5c0c7186ff
commit 3659608abe
+7
View File
@@ -4,6 +4,13 @@ import path from 'path';
import sharp from 'sharp';
import { rotateInPlace } from '../../src/imageProcessing';
// libvips keeps an input file mapped in its operation cache after a pipeline
// finishes, and Windows will not delete a file that still has an open handle —
// so the animated-WebP case, which is the one that ends in a rejection, left
// afterEach unable to remove its own temporary directory. Disabling the cache
// costs these six tests nothing: every one of them reads its file exactly once.
sharp.cache(false);
let dir = '';
beforeEach(async () => {