diff --git a/test/parallel/test-crypto-deprecated.js b/test/parallel/test-crypto-deprecated.js index c702e9129ac956..a471b192e1ff45 100644 --- a/test/parallel/test-crypto-deprecated.js +++ b/test/parallel/test-crypto-deprecated.js @@ -9,6 +9,11 @@ if (!common.hasCrypto) { const crypto = require('crypto'); const tls = require('tls'); +const expected = [ + 'crypto.Credentials is deprecated. Use tls.SecureContext instead.', + 'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.' +]; + process.on('warning', common.mustCall((warning) => { assert.strictEqual(warning.name, 'DeprecationWarning'); assert.notStrictEqual(expected.indexOf(warning.message), -1, @@ -16,12 +21,7 @@ process.on('warning', common.mustCall((warning) => { // Remove a warning message after it is seen so that we guarantee that we get // each message only once. expected.splice(expected.indexOf(warning.message), 1); -}, 2)); - -var expected = [ - 'crypto.Credentials is deprecated. Use tls.SecureContext instead.', - 'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.' -]; +}, expected.length)); // Accessing the deprecated function is enough to trigger the warning event. // It does not need to be called. So the assert serves the purpose of both