From b701567a46c2988a368d715d52d80fe605d7d4fd Mon Sep 17 00:00:00 2001 From: Evgenia Blajer <44325210+bliakher@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:19:42 +0000 Subject: [PATCH] test: replace forEach() with for .. of PR-URL: https://github.com/nodejs/node/pull/50605 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-async-wrap-constructor.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-async-wrap-constructor.js b/test/parallel/test-async-wrap-constructor.js index e89bc49df02333..853898aa0adf1a 100644 --- a/test/parallel/test-async-wrap-constructor.js +++ b/test/parallel/test-async-wrap-constructor.js @@ -6,15 +6,16 @@ require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); -[0, 1, false, true, null, 'hello'].forEach((badArg) => { +const falsyValues = [0, 1, false, true, null, 'hello']; +for (const badArg of falsyValues) { const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve']; - hookNames.forEach((field) => { + for (const hookName of hookNames) { assert.throws(() => { - async_hooks.createHook({ [field]: badArg }); + async_hooks.createHook({ [hookName]: badArg }); }, { code: 'ERR_ASYNC_CALLBACK', name: 'TypeError', - message: `hook.${field} must be a function` + message: `hook.${hookName} must be a function` }); - }); -}); + } +}