Skip to content

Commit

Permalink
ignore locate error in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans committed Dec 4, 2023
1 parent ff2ae86 commit 6543a60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/tracing/locate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion test/tracing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down

0 comments on commit 6543a60

Please sign in to comment.