From 6543a60b6b719a0fb54a2011e08b5a763c7a1c12 Mon Sep 17 00:00:00 2001 From: D050513 Date: Mon, 4 Dec 2023 11:35:41 +0100 Subject: [PATCH] ignore locate error in tests --- lib/tracing/locate.js | 8 ++++++-- test/tracing.test.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/tracing/locate.js b/lib/tracing/locate.js index 23427d2..dcd121b 100644 --- a/lib/tracing/locate.js +++ b/lib/tracing/locate.js @@ -22,7 +22,8 @@ module.exports = async fn => { }) const session_post = promisify(session.post).bind(session) await session_post('Debugger.enable') - const { result: { objectId } } = await session_post('Runtime.evaluate', { expression: random }) + const expression = `global.${random}` + const { result: { objectId } } = await session_post('Runtime.evaluate', { expression }) const { internalProperties } = await session_post('Runtime.getProperties', { objectId }) const function_location = internalProperties.find(({ name }) => name === '[[FunctionLocation]]') const location = { @@ -33,7 +34,10 @@ module.exports = async fn => { locations.set(fn, location) return location } catch (err) { - LOG.warn(`Unable to locate function "${fn.name}" due to error:`, err) + // REVISIT: the above does not work in tests (jest?) + if (process.env.NODE_ENV !== 'test' && LOG._warn) { + LOG.warn(`Unable to locate function "${fn.name}" due to error:`, err) + } } finally { session?.disconnect() delete global[random] diff --git a/test/tracing.test.js b/test/tracing.test.js index 2ecfbc4..cbb434e 100644 --- a/test/tracing.test.js +++ b/test/tracing.test.js @@ -13,7 +13,7 @@ describe('Integration tests cds with open telemetry', () => { const { status } = await GET('/odata/v4/admin/Books', admin) expect(status).to.equal(200) // primitive check that console has trace logs - expect(log.output).to.match(/\[otel\] - \s+\d+\.\d+ ms/) + expect(log.output).to.match(/\[telemetry\] - \s+\d+\.\d+ ms/) }) // --- HERE ---