client-stack.client.spec.ts 1014 B

12345678910111213141516171819202122232425262728293031
  1. import { describe, expect, it } from 'vitest'
  2. import { parseClientStack } from '../src/client/cdp/stack.ts'
  3. import { inspectorId } from '../src/shared/bridge/ids.ts'
  4. describe('Client stack projection', () => {
  5. it('normalizes browser line numbers and associates known source URLs', () => {
  6. const key = inspectorId<'RuntimeScriptKey'>('client-bundle', 'scriptKey')
  7. const stack = parseClientStack([
  8. 'Error',
  9. ' at capture (http://client.test/client.js?rev=1:10:4)',
  10. ' at http://client.test/app.js:20:8',
  11. ].join('\n'), url => url.includes('/client.js') ? key : undefined, 0)
  12. expect(stack).toEqual({
  13. callFrames: [
  14. {
  15. functionName: 'capture',
  16. scriptKey: key,
  17. url: 'http://client.test/client.js?rev=1',
  18. lineNumber: 9,
  19. columnNumber: 3,
  20. },
  21. {
  22. functionName: '',
  23. url: 'http://client.test/app.js',
  24. lineNumber: 19,
  25. columnNumber: 7,
  26. },
  27. ],
  28. })
  29. })
  30. })