From 28e64598d32ad198fa09b1587866a378fa96e1e4 Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Sun, 8 Mar 2026 08:27:32 -0600 Subject: [PATCH] fix `assert.rejects` usage in tests `assert.rejects` needs to be awaited inside of the async test body if it is not the test is effectively ignored since any exceptions are thrown after the test function completes other changes: - `transform` option is required by plugin - wrapping a Promise returned by `Metalsmith` invocation is not necessary: `assert.rejects` takes a Promise as first argument see: https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message --- test/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/index.js b/test/index.js index 55c8389..8d4cb59 100644 --- a/test/index.js +++ b/test/index.js @@ -196,13 +196,11 @@ describe('@metalsmith/layouts', () => { it('should return an error for an invalid pattern', async () => { const { dir } = fixture('invalid-pattern') - rejects( - async () => { - await Metalsmith(dir) - .env('DEBUG', process.env.DEBUG) - .use(plugin({ pattern: () => {} })) - .build() - }, + await rejects( + Metalsmith(dir) + .env('DEBUG', process.env.DEBUG) + .use(plugin({ transform: 'handlebars', pattern: () => {} })) + .build(), { message: 'invalid pattern, the pattern option should be a string or array of strings.' } ) })