Skip to content

Conversation

@kleisauke
Copy link
Contributor

After migrating to the Node.js native test runner, I found that several text-related tests were timing out at 60 seconds when using a globally-installed libvips.

Details
...
▶ Text to image
  ﹣ text with default values (2.558585ms) # SKIP
  ﹣ text with width and height (60000.243835ms) # SKIP
  ﹣ text with dpi (60006.379163ms) # SKIP
  ﹣ text with color and pango markup (60001.064501ms) # SKIP
  ﹣ text with font (60005.997102ms) # SKIP
  ﹣ text with justify and composite (60000.452162ms) # SKIP
  ✔ bad text input (0.401089ms)
  ✔ fontfile input (0.14158ms)
  ✔ bad font input (0.108329ms)
  ✔ bad fontfile input (0.10318ms)
  ✔ invalid width (0.35421ms)
  ✔ invalid height (0.229579ms)
  ✔ bad align input (0.09351ms)
  ✔ bad justify input (0.09659ms)
  ✔ invalid dpi (0.20053ms)
  ✔ bad rgba input (0.089959ms)
  ✔ invalid spacing (0.708499ms)
  ✔ only height or dpi not both (0.09129ms)
  ✔ valid wrap throws (0.09076ms)
  ✔ invalid wrap throws (0.14912ms)
...

test at test/unit/text.js:42:3
﹣ text with width and height (60000.243835ms) # SKIP
  'test timed out after 60000ms'

test at test/unit/text.js:65:3
﹣ text with dpi (60006.379163ms) # SKIP
  'test timed out after 60000ms'

test at test/unit/text.js:88:3
﹣ text with color and pango markup (60001.064501ms) # SKIP
  'test timed out after 60000ms'

test at test/unit/text.js:115:3
﹣ text with font (60005.997102ms) # SKIP
  'test timed out after 60000ms'

test at test/unit/text.js:136:3
﹣ text with justify and composite (60000.452162ms) # SKIP
  'test timed out after 60000ms'

It appears that, unlike Mocha, the Node.js test runner doesn't automatically call done() when t.skip() is called.

This can also be fixed by doing the following:

Details
--- a/test/unit/text.js
+++ b/test/unit/text.js
@@ -49,7 +49,8 @@ describe('Text to image', function () {
       }
     });
     if (!sharp.versions.pango) {
-      return t.skip();
+      t.skip();
+      return done();
     }
     text.toFile(output, function (err, info) {
       if (err) throw err;
@@ -72,7 +73,8 @@ describe('Text to image', function () {
       }
     });
     if (!sharp.versions.pango) {
-      return t.skip();
+      t.skip();
+      return done();
     }
     text.toFile(output, function (err, info) {
       if (err) throw err;
@@ -96,7 +98,8 @@ describe('Text to image', function () {
       }
     });
     if (!sharp.versions.pango) {
-      return t.skip();
+      t.skip();
+      return done();
     }
     text.toFile(output, function (err, info) {
       if (err) throw err;
@@ -121,7 +124,8 @@ describe('Text to image', function () {
       }
     });
     if (!sharp.versions.pango) {
-      return t.skip();
+      t.skip();
+      return done();
     }
     text.toFile(output, function (err, info) {
       if (err) throw err;
@@ -165,7 +169,8 @@ describe('Text to image', function () {
         top: 250
       }]);
     if (!sharp.versions.pango) {
-      return t.skip();
+      t.skip();
+      return done();
     }
     text.toFile(output, function (err, info) {
       if (err) throw err;

But this approach is probably a bit neater.

@lovell lovell merged commit 69b2c45 into lovell:main Oct 27, 2025
31 checks passed
@lovell
Copy link
Owner

lovell commented Oct 27, 2025

Dankjewel!

@kleisauke kleisauke deleted the text-tests-async branch October 27, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants