Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions test/fetch/client-error-stack-trace.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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.<anonymous> (${__filename}`))
}
Expand All @@ -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.<anonymous> (${__filename}`))
}
Expand Down
Loading