From cdd8e8c8aac4e82dc7dd091eb768edac4237f985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Matte?= Date: Mon, 2 Jun 2025 18:42:57 -0400 Subject: [PATCH] Use folder provided --- lib/suite.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/suite.js b/lib/suite.js index 26c93b9..0fba677 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -1,23 +1,8 @@ +import path from 'node:path' import { walkDir } from './walkDir.js' -import { join } from 'node:path' -import { fileURLToPath } from 'node:url' -import { dirname } from 'node:path' -const getStackAbsolutePaths = () => { - const old = Error.prepareStackTrace - Error.prepareStackTrace = (_, stack) => stack - const stack = new Error().stack - Error.prepareStackTrace = old - - return stack - .map(cs => cs.getFileName()) - .filter(filename => filename?.startsWith('file://')) - .map(filename => dirname(fileURLToPath(filename))) -} - import { summaryreporter, errorreporter, totalreporter } from 'metaltest' + const suite = async (folder = '.') => { - const absolutePaths = getStackAbsolutePaths() - const absolutePath = absolutePaths[2] const fileIgnored = [] const total = totalreporter() @@ -25,7 +10,7 @@ const suite = async (folder = '.') => { for await (const file of walkDir(folder, ['node_modules', '.git'])) { if (!file.endsWith('.test.js')) continue - const module = join(absolutePath, file) + const module = path.resolve(folder, file) const { test } = await import(module) if (test === undefined) {