diff --git a/test/fetch/client-error-stack-trace.js b/test/fetch/client-error-stack-trace.js index a49d9d654cd..812f1076793 100644 --- a/test/fetch/client-error-stack-trace.js +++ b/test/fetch/client-error-stack-trace.js @@ -1,8 +1,10 @@ 'use strict' const { test } = require('node:test') -const { sep } = require('node:path') +const { sep, basename, join } = require('node:path') const { fetch, setGlobalDispatcher, Agent } = require('../..') + +const projectFolder = basename(join(__dirname, '..', '..')) const { fetch: fetchIndex } = require('../../index-fetch') setGlobalDispatcher(new Agent({ @@ -16,7 +18,7 @@ test('FETCH: request errors and prints trimmed stack trace', async (t) => { } catch (error) { const stackLines = error.stack.split('\n') t.assert.ok(stackLines[0].includes('TypeError: fetch failed')) - t.assert.ok(stackLines[1].includes(`undici${sep}index.js`)) + t.assert.ok(stackLines[1].includes(`${projectFolder}${sep}index.js`)) t.assert.ok(stackLines[2].includes('at process.processTicksAndRejections')) t.assert.ok(stackLines[3].includes(`at async TestContext. (${__filename}`)) } @@ -28,7 +30,7 @@ test('FETCH-index: request errors and prints trimmed stack trace', async (t) => } catch (error) { const stackLines = error.stack.split('\n') t.assert.ok(stackLines[0].includes('TypeError: fetch failed')) - t.assert.ok(stackLines[1].includes(`undici${sep}index-fetch.js`)) + t.assert.ok(stackLines[1].includes(`${projectFolder}${sep}index-fetch.js`)) t.assert.ok(stackLines[2].includes('at process.processTicksAndRejections')) t.assert.ok(stackLines[3].includes(`at async TestContext. (${__filename}`)) }