Skip to content

Commit ec4a84e

Browse files
authored
fix(test): remove hardcoded folder name in client-error-stack-trace test (#4707)
1 parent 59fd5f4 commit ec4a84e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/fetch/client-error-stack-trace.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
'use strict'
22

33
const { test } = require('node:test')
4-
const { sep } = require('node:path')
4+
const { sep, basename, join } = require('node:path')
55
const { fetch, setGlobalDispatcher, Agent } = require('../..')
6+
7+
const projectFolder = basename(join(__dirname, '..', '..'))
68
const { fetch: fetchIndex } = require('../../index-fetch')
79

810
setGlobalDispatcher(new Agent({
@@ -16,7 +18,7 @@ test('FETCH: request errors and prints trimmed stack trace', async (t) => {
1618
} catch (error) {
1719
const stackLines = error.stack.split('\n')
1820
t.assert.ok(stackLines[0].includes('TypeError: fetch failed'))
19-
t.assert.ok(stackLines[1].includes(`undici${sep}index.js`))
21+
t.assert.ok(stackLines[1].includes(`${projectFolder}${sep}index.js`))
2022
t.assert.ok(stackLines[2].includes('at process.processTicksAndRejections'))
2123
t.assert.ok(stackLines[3].includes(`at async TestContext.<anonymous> (${__filename}`))
2224
}
@@ -28,7 +30,7 @@ test('FETCH-index: request errors and prints trimmed stack trace', async (t) =>
2830
} catch (error) {
2931
const stackLines = error.stack.split('\n')
3032
t.assert.ok(stackLines[0].includes('TypeError: fetch failed'))
31-
t.assert.ok(stackLines[1].includes(`undici${sep}index-fetch.js`))
33+
t.assert.ok(stackLines[1].includes(`${projectFolder}${sep}index-fetch.js`))
3234
t.assert.ok(stackLines[2].includes('at process.processTicksAndRejections'))
3335
t.assert.ok(stackLines[3].includes(`at async TestContext.<anonymous> (${__filename}`))
3436
}

0 commit comments

Comments
 (0)