123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import {Frame} from 'sentry/utils/profiling/frame';
- describe('Frame', () => {
- describe.each([['javascript'], ['node']])(
- 'renames unknown frame to <anonymous> for platform %s',
- platform => {
- it('sets anonymouse name if frame has no name', () => {
- expect(new Frame({key: 0, name: '', line: 0, column: 0}, platform).name).toBe(
- '<anonymous>'
- );
- });
- it('appends [native code] to name if frame belongs to native code', () => {
- expect(
- new Frame(
- {key: 0, name: 'foo', line: undefined, column: undefined},
- platform
- ).name.endsWith('[native code]')
- ).toBe(true);
- });
- }
- );
- it('marks frame as extension', () => {
- for (const prefix of ['@moz-extension://', 'chrome-extension://']) {
- expect(
- new Frame(
- {
- key: 0,
- name: 'foo',
- line: undefined,
- column: undefined,
- file: `${prefix}foo/bar.js`,
- },
- 'javascript'
- ).is_browser_extension
- ).toBe(true);
- }
- expect(
- new Frame(
- {
- key: 0,
- name: 'foo',
- line: undefined,
- column: undefined,
- file: `bar.js`,
- },
- 'javascript'
- ).is_browser_extension
- ).toBe(false);
- });
- describe('pulls package from path for web|node platforms', () => {
- it('file in node modules', () => {
- expect(
- new Frame(
- {
- key: 0,
- name: 'Foo',
- path: '/usr/code/node_modules/file.js',
- line: undefined,
- column: undefined,
- },
- 'node'
- ).module
- ).toBe(undefined);
- });
- it.each([
- ['node:internal/crypto/hash', 'node:internal/crypto'],
- ['node:vm', 'node:vm'],
- ['/usr/code/node_modules/@sentry/profiling-node/file.js', '@sentry/profiling-node'],
- ['/usr/code/node_modules/sentry/profiling-node/file.js', 'sentry'],
- ['/usr/code/node_modules/sentry/file.js', 'sentry'],
- [
- 'C:\\Program Files (x86)\\node_modules\\@sentry\\profiling-node\\file.js',
- '@sentry/profiling-node',
- ],
- [
- 'C:\\Program Files (x86)\\node_modules\\sentry\\profiling-node\\file.js',
- 'sentry',
- ],
- ['C:\\Program Files (x86)\\node_modules\\sentry\\file.js', 'sentry'],
- ])('%s -> %s', (path, expected) => {
- expect(
- new Frame(
- {
- key: 0,
- name: 'Foo',
- path,
- line: undefined,
- column: undefined,
- },
- 'node'
- ).module
- ).toBe(expected);
- });
- });
- });
|