From eb76b8163dd49a6501de0a3b928d3998803cb2bf Mon Sep 17 00:00:00 2001 From: Will Harney Date: Mon, 18 Mar 2024 12:09:20 -0400 Subject: [PATCH] patch removed util methods for vows --- package.json | 2 +- test/scripts/vows.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 test/scripts/vows.js diff --git a/package.json b/package.json index caf37ae8..79b38ec7 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "version": "genversion --es6 lib/version.ts && git add lib/version.ts", "test": "npm run test:ts && npm run test:legacy", "test:ts": "jest", - "test:legacy": "npm run build -- --declaration false && vows test/*_test.js", + "test:legacy": "npm run build -- --declaration false && ./test/scripts/vows.js test/*_test.js", "typecheck": "tsc --noEmit", "cover": "jest --coverage", "eslint": "eslint --env node --ext .ts .", diff --git a/test/scripts/vows.js b/test/scripts/vows.js new file mode 100755 index 00000000..07ab46ad --- /dev/null +++ b/test/scripts/vows.js @@ -0,0 +1,15 @@ +#!/usr/bin/env node +/** + * @fileoverview Vows logs using methods from `util` that were removed in node v12. To avoid cryptic + * error messages when tests fail, we patch those methods using `console.log`. + * @see {@link https://nodejs.org/api/deprecations.html#DEP0026|`util.print` deprecation} + * @see {@link https://nodejs.org/api/deprecations.html#DEP0027|`util.puts` deprecation} + * @see {@link https://nodejs.org/docs/latest-v0.10.x/api/util.html|Docs for deprecated `util` methods} + */ + +// Patch deprecated util methods +const util = require("node:util"); +util.print = (...args) => console.log(args.join('')); +util.puts = (...args) => console.log(args.join('\n')); +// Call vows executable +require("vows/bin/vows");