@newrelic/browser-agent 1.235.0 → 1.237.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/cjs/common/config/state/init.js +4 -0
- package/dist/cjs/common/config/state/runtime.js +6 -5
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +52 -0
- package/dist/cjs/common/deny-list/deny-list.js +14 -10
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
- package/dist/cjs/common/harvest/harvest.js +154 -148
- package/dist/cjs/common/harvest/types.js +54 -0
- package/dist/cjs/common/ids/id.js +2 -2
- package/dist/cjs/common/ids/unique-id.js +3 -3
- package/dist/cjs/common/session/session-entity.js +2 -2
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +10 -11
- package/dist/cjs/common/url/canonicalize-url.js +2 -2
- package/dist/cjs/common/url/parse-url.js +3 -3
- package/dist/cjs/common/url/protocol.js +2 -2
- package/dist/cjs/common/util/submit-data.js +31 -81
- package/dist/cjs/common/window/nreum.js +14 -14
- package/dist/cjs/common/wrap/wrap-events.js +3 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
- package/dist/cjs/common/wrap/wrap-history.js +2 -2
- package/dist/cjs/common/wrap/wrap-jsonp.js +14 -8
- package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -2
- package/dist/cjs/common/wrap/wrap-raf.js +2 -2
- package/dist/cjs/common/wrap/wrap-timer.js +4 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +25 -28
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +6 -7
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
- package/dist/cjs/features/jserrors/constants.js +2 -4
- package/dist/cjs/features/jserrors/instrument/index.js +80 -89
- package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +3 -3
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +65 -34
- package/dist/cjs/features/session_replay/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
- package/dist/cjs/features/session_trace/instrument/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +12 -15
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent-base.js +87 -0
- package/dist/cjs/loaders/agent.js +48 -1
- package/dist/cjs/loaders/api/api.js +3 -3
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/api/interaction-types.js +87 -0
- package/dist/cjs/loaders/configure/configure.js +4 -3
- package/dist/cjs/loaders/micro-agent.js +32 -39
- package/dist/esm/common/config/state/init.js +4 -0
- package/dist/esm/common/config/state/runtime.js +3 -2
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +38 -0
- package/dist/esm/common/deny-list/deny-list.js +14 -10
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
- package/dist/esm/common/harvest/harvest.js +150 -146
- package/dist/esm/common/harvest/types.js +47 -0
- package/dist/esm/common/ids/id.js +1 -1
- package/dist/esm/common/ids/unique-id.js +1 -1
- package/dist/esm/common/session/session-entity.js +1 -1
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/unload/eol.js +1 -2
- package/dist/esm/common/url/canonicalize-url.js +1 -1
- package/dist/esm/common/url/parse-url.js +1 -1
- package/dist/esm/common/url/protocol.js +1 -1
- package/dist/esm/common/util/submit-data.js +29 -78
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +1 -1
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +13 -7
- package/dist/esm/common/wrap/wrap-mutation.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/common/wrap/wrap-raf.js +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +26 -29
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -2
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -3
- package/dist/esm/features/jserrors/constants.js +1 -2
- package/dist/esm/features/jserrors/instrument/index.js +79 -88
- package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +65 -34
- package/dist/esm/features/session_replay/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/aggregate/index.js +3 -4
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +11 -14
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent-base.js +80 -0
- package/dist/esm/loaders/agent.js +48 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/api/interaction-types.js +80 -0
- package/dist/esm/loaders/configure/configure.js +4 -3
- package/dist/esm/loaders/micro-agent.js +32 -39
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +49 -38
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +100 -0
- package/dist/types/common/harvest/types.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +6 -6
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +44 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/constants.d.ts +0 -1
- package/dist/types/features/jserrors/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loaders/agent-base.d.ts +59 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +39 -5
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +122 -0
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +6 -6
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +2 -1
- package/src/common/config/state/runtime.js +3 -2
- package/src/common/constants/__mocks__/env.js +3 -0
- package/src/common/constants/__mocks__/runtime.js +8 -0
- package/src/common/constants/env.cdn.test.js +7 -0
- package/src/common/constants/env.npm.test.js +7 -0
- package/src/common/constants/env.test.js +7 -0
- package/src/common/constants/runtime.js +71 -0
- package/src/common/constants/runtime.test.js +168 -0
- package/src/common/context/__mocks__/shared-context.js +8 -0
- package/src/common/deny-list/deny-list.js +11 -11
- package/src/common/deny-list/deny-list.test.js +31 -0
- package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/__mocks__/harvest.js +13 -0
- package/src/common/harvest/harvest-scheduler.js +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +142 -134
- package/src/common/harvest/harvest.test.js +798 -0
- package/src/common/harvest/types.js +47 -0
- package/src/common/ids/id.js +1 -1
- package/src/common/ids/unique-id.js +1 -1
- package/src/common/session/__mocks__/session-entity.js +25 -0
- package/src/common/session/session-entity.component-test.js +1 -1
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timing/__mocks__/now.js +1 -0
- package/src/common/unload/__mocks__/eol.js +1 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/__mocks__/clean-url.js +1 -0
- package/src/common/url/__mocks__/encode.js +7 -0
- package/src/common/url/__mocks__/location.js +1 -0
- package/src/common/url/canonicalize-url.js +1 -1
- package/src/common/url/canonicalize-url.test.js +2 -2
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +5 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +22 -58
- package/src/common/util/submit-data.test.js +30 -73
- package/src/common/window/nreum.js +1 -1
- package/src/common/wrap/wrap-events.js +1 -1
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-history.js +1 -1
- package/src/common/wrap/wrap-jsonp.js +12 -7
- package/src/common/wrap/wrap-mutation.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/common/wrap/wrap-promise.test.js +2 -2
- package/src/common/wrap/wrap-raf.js +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +26 -32
- package/src/features/ajax/instrument/distributed-tracing.js +1 -1
- package/src/features/ajax/instrument/index.js +1 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +7 -3
- package/src/features/jserrors/constants.js +0 -1
- package/src/features/jserrors/instrument/index.js +92 -88
- package/src/features/jserrors/instrument/uncaught-error.js +15 -0
- package/src/features/metrics/aggregate/framework-detection.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/aggregate/initialized-features.js +18 -14
- package/src/features/page_view_event/instrument/index.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +2 -4
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.component-test.js +17 -56
- package/src/features/session_replay/aggregate/index.js +47 -28
- package/src/features/session_replay/replay-mode.js +2 -2
- package/src/features/session_trace/aggregate/index.js +3 -4
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.test.js +2 -2
- package/src/features/utils/instrument-base.js +11 -14
- package/src/features/utils/instrument-base.test.js +29 -3
- package/src/index.js +1 -3
- package/src/loaders/agent-base.js +81 -0
- package/src/loaders/agent.js +50 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/api/interaction-types.js +80 -0
- package/src/loaders/configure/configure.js +5 -4
- package/src/loaders/micro-agent.js +30 -31
- package/dist/cjs/common/browser-version/firefox-version.js +0 -17
- package/dist/cjs/common/browser-version/ios-version.js +0 -19
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
- package/dist/cjs/common/event-emitter/handle.test.js +0 -58
- package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
- package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
- package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
- package/dist/cjs/common/ids/id.test.js +0 -85
- package/dist/cjs/common/ids/unique-id.test.js +0 -49
- package/dist/cjs/common/session/session-entity.component-test.js +0 -497
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
- package/dist/cjs/common/timer/timer.test.js +0 -105
- package/dist/cjs/common/timing/nav-timing.test.js +0 -192
- package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.component-test.js +0 -74
- package/dist/cjs/common/url/location.test.js +0 -13
- package/dist/cjs/common/url/parse-url.test.js +0 -111
- package/dist/cjs/common/url/protocol.component-test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -64
- package/dist/cjs/common/util/feature-flags.test.js +0 -84
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -27
- package/dist/cjs/common/util/global-scope.test.js +0 -72
- package/dist/cjs/common/util/invoke.test.js +0 -49
- package/dist/cjs/common/util/map-own.test.js +0 -49
- package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
- package/dist/cjs/common/util/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -245
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/jserrors/instrument/debug.js +0 -40
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- package/dist/cjs/features/utils/agent-session.test.js +0 -211
- package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
- package/dist/cjs/features/utils/feature-base.test.js +0 -42
- package/dist/cjs/features/utils/handler-cache.test.js +0 -53
- package/dist/cjs/features/utils/instrument-base.test.js +0 -179
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
- package/dist/esm/common/browser-version/firefox-version.js +0 -10
- package/dist/esm/common/browser-version/ios-version.js +0 -11
- package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
- package/dist/esm/common/event-emitter/handle.test.js +0 -54
- package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
- package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
- package/dist/esm/common/harvest/harvest.component-test.js +0 -222
- package/dist/esm/common/ids/id.test.js +0 -81
- package/dist/esm/common/ids/unique-id.test.js +0 -44
- package/dist/esm/common/session/session-entity.component-test.js +0 -495
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
- package/dist/esm/common/timer/timer.test.js +0 -103
- package/dist/esm/common/timing/nav-timing.test.js +0 -190
- package/dist/esm/common/url/canonicalize-url.test.js +0 -34
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.component-test.js +0 -70
- package/dist/esm/common/url/location.test.js +0 -11
- package/dist/esm/common/url/parse-url.test.js +0 -107
- package/dist/esm/common/url/protocol.component-test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -60
- package/dist/esm/common/util/feature-flags.test.js +0 -80
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -17
- package/dist/esm/common/util/global-scope.test.js +0 -70
- package/dist/esm/common/util/invoke.test.js +0 -47
- package/dist/esm/common/util/map-own.test.js +0 -47
- package/dist/esm/common/util/obfuscate.component-test.js +0 -125
- package/dist/esm/common/util/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -241
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/jserrors/instrument/debug.js +0 -38
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- package/dist/esm/features/utils/agent-session.test.js +0 -207
- package/dist/esm/features/utils/aggregate-base.test.js +0 -108
- package/dist/esm/features/utils/feature-base.test.js +0 -40
- package/dist/esm/features/utils/handler-cache.test.js +0 -51
- package/dist/esm/features/utils/instrument-base.test.js +0 -175
- package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
- package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
- package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
- package/dist/types/common/browser-version/ios-version.d.ts +0 -3
- package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
- package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
- package/dist/types/common/url/encode.component-test.d.ts +0 -2
- package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
- package/dist/types/common/url/protocol.component-test.d.ts +0 -2
- package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -5
- package/dist/types/common/util/global-scope.d.ts.map +0 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
- package/dist/types/features/jserrors/instrument/debug.d.ts +0 -2
- package/dist/types/features/jserrors/instrument/debug.d.ts.map +0 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
- package/src/common/browser-version/firefox-version.js +0 -10
- package/src/common/browser-version/ios-version.js +0 -11
- package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
- package/src/common/harvest/harvest.component-test.js +0 -169
- package/src/common/util/global-scope.js +0 -23
- package/src/common/util/global-scope.test.js +0 -87
- package/src/features/jserrors/instrument/debug.js +0 -36
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { stringify } from './stringify';
|
|
2
|
-
var mockEmit = jest.fn();
|
|
3
|
-
jest.mock('../event-emitter/contextual-ee', () => ({
|
|
4
|
-
__esModule: true,
|
|
5
|
-
get ee() {
|
|
6
|
-
return {
|
|
7
|
-
emit: mockEmit
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}));
|
|
11
|
-
test('should return a JSON string representation of the value', () => {
|
|
12
|
-
const obj = {
|
|
13
|
-
a: 1,
|
|
14
|
-
b: {
|
|
15
|
-
nested: true
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const expected = '{"a":1,"b":{"nested":true}}';
|
|
19
|
-
const result = stringify(obj);
|
|
20
|
-
expect(result).toBe(expected);
|
|
21
|
-
});
|
|
22
|
-
test('should handle circular references and exclude them from the JSON output', () => {
|
|
23
|
-
const obj = {
|
|
24
|
-
a: 1
|
|
25
|
-
};
|
|
26
|
-
obj.b = obj; // Create a circular reference
|
|
27
|
-
const expected = '{"a":1}';
|
|
28
|
-
const result = stringify(obj);
|
|
29
|
-
expect(result).toBe(expected);
|
|
30
|
-
});
|
|
31
|
-
test('should handle non-object values and return their string representation', () => {
|
|
32
|
-
const value = 42;
|
|
33
|
-
const expected = '42';
|
|
34
|
-
const result = stringify(value);
|
|
35
|
-
expect(result).toBe(expected);
|
|
36
|
-
});
|
|
37
|
-
test('should emit an "internal-error" event if an error occurs during JSON.stringify', () => {
|
|
38
|
-
const obj = {
|
|
39
|
-
a: 1
|
|
40
|
-
};
|
|
41
|
-
jest.spyOn(JSON, 'stringify').mockImplementation(() => {
|
|
42
|
-
throw new Error('message');
|
|
43
|
-
});
|
|
44
|
-
stringify(obj);
|
|
45
|
-
expect(mockEmit).toHaveBeenCalledWith('internal-error', expect.any(Array));
|
|
46
|
-
});
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
* @jest-environment-options {"html": "<html><head><script></script></head><body></body></html>", "url": "https://example.com/"}
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { faker } from '@faker-js/faker';
|
|
7
|
-
import { submitData } from './submit-data';
|
|
8
|
-
import * as globalScope from './global-scope';
|
|
9
|
-
jest.mock('./global-scope');
|
|
10
|
-
const url = 'https://example.com/api';
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
jest.restoreAllMocks();
|
|
13
|
-
});
|
|
14
|
-
describe('submitData.jsonp', () => {
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
jest.replaceProperty(globalScope, 'isWorkerScope', false);
|
|
17
|
-
});
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
delete global.importScripts;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// This test requires a script tag to exist in the html set by this file's jest-environment-options header block.
|
|
23
|
-
test('should return an HTMLScriptElement when called from a web window environment', () => {
|
|
24
|
-
const jsonp = faker.datatype.uuid();
|
|
25
|
-
const result = submitData.jsonp({
|
|
26
|
-
url,
|
|
27
|
-
jsonp
|
|
28
|
-
});
|
|
29
|
-
expect(result).toBeInstanceOf(HTMLScriptElement);
|
|
30
|
-
expect(result.type).toBe('text/javascript');
|
|
31
|
-
expect(result.src).toBe(url + '&jsonp=' + jsonp);
|
|
32
|
-
});
|
|
33
|
-
test('should try to use importScripts when called from a worker scope', () => {
|
|
34
|
-
jest.replaceProperty(globalScope, 'isWorkerScope', true);
|
|
35
|
-
global.importScripts = jest.fn();
|
|
36
|
-
const jsonp = faker.datatype.uuid();
|
|
37
|
-
submitData.jsonp({
|
|
38
|
-
url,
|
|
39
|
-
jsonp
|
|
40
|
-
});
|
|
41
|
-
expect(global.importScripts).toHaveBeenCalledWith(url + '&jsonp=' + jsonp);
|
|
42
|
-
});
|
|
43
|
-
test('should fall back to an xhrGet call and return false when importScripts throws an error', () => {
|
|
44
|
-
jest.replaceProperty(globalScope, 'isWorkerScope', true);
|
|
45
|
-
jest.spyOn(submitData, 'xhrGet').mockImplementation(jest.fn());
|
|
46
|
-
global.importScripts = jest.fn().mockImplementation(() => {
|
|
47
|
-
throw new Error(faker.lorem.sentence());
|
|
48
|
-
});
|
|
49
|
-
const jsonp = faker.datatype.uuid();
|
|
50
|
-
const result = submitData.jsonp({
|
|
51
|
-
url,
|
|
52
|
-
jsonp
|
|
53
|
-
});
|
|
54
|
-
expect(result).toBe(false);
|
|
55
|
-
expect(global.importScripts).toHaveBeenCalledWith(url + '&jsonp=' + jsonp);
|
|
56
|
-
expect(submitData.xhrGet).toHaveBeenCalledWith({
|
|
57
|
-
url: url + '&jsonp=' + jsonp
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
test('should not throw an error when xhrGet throws an error', () => {
|
|
61
|
-
jest.replaceProperty(globalScope, 'isWorkerScope', true);
|
|
62
|
-
jest.spyOn(submitData, 'xhrGet').mockImplementation(() => {
|
|
63
|
-
throw new Error(faker.lorem.sentence());
|
|
64
|
-
});
|
|
65
|
-
global.importScripts = jest.fn().mockImplementation(() => {
|
|
66
|
-
throw new Error(faker.lorem.sentence());
|
|
67
|
-
});
|
|
68
|
-
const jsonp = faker.datatype.uuid();
|
|
69
|
-
expect(() => submitData.jsonp({
|
|
70
|
-
url,
|
|
71
|
-
jsonp
|
|
72
|
-
})).not.toThrow();
|
|
73
|
-
});
|
|
74
|
-
test('should not throw an error when element insertion fails', () => {
|
|
75
|
-
jest.spyOn(document, 'createElement').mockImplementation(() => {
|
|
76
|
-
throw new Error(faker.lorem.sentence());
|
|
77
|
-
});
|
|
78
|
-
const jsonp = faker.datatype.uuid();
|
|
79
|
-
expect(() => submitData.jsonp({
|
|
80
|
-
url,
|
|
81
|
-
jsonp
|
|
82
|
-
})).not.toThrow();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('submitData.xhrGet', () => {
|
|
86
|
-
test('xhrGet should call xhr with GET as the method', () => {
|
|
87
|
-
jest.spyOn(submitData, 'xhr').mockReturnValue(new XMLHttpRequest());
|
|
88
|
-
const result = submitData.xhrGet({
|
|
89
|
-
url
|
|
90
|
-
});
|
|
91
|
-
expect(result).toBeInstanceOf(XMLHttpRequest);
|
|
92
|
-
expect(submitData.xhr).toHaveBeenCalledWith({
|
|
93
|
-
url,
|
|
94
|
-
sync: false,
|
|
95
|
-
method: 'GET'
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
describe('submitData.xhr', () => {
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
102
|
-
this.prototype = XMLHttpRequest.prototype;
|
|
103
|
-
this.open = jest.fn();
|
|
104
|
-
this.send = jest.fn();
|
|
105
|
-
this.setRequestHeader = jest.fn();
|
|
106
|
-
this._withCredentials = false;
|
|
107
|
-
Object.defineProperty(this, 'withCredentials', {
|
|
108
|
-
get: jest.fn(() => this._withCredentials),
|
|
109
|
-
set: jest.fn(val => this._withCredentials = val)
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
test('should make and send an xhr with default values', () => {
|
|
114
|
-
const result = submitData.xhr({
|
|
115
|
-
url
|
|
116
|
-
});
|
|
117
|
-
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0];
|
|
118
|
-
expect(result).toBeInstanceOf(XMLHttpRequest);
|
|
119
|
-
expect(result.withCredentials).toBe(true);
|
|
120
|
-
expect(xhr.open).toHaveBeenCalledWith('POST', url, true);
|
|
121
|
-
expect(xhr.setRequestHeader).toHaveBeenCalledWith('content-type', 'text/plain');
|
|
122
|
-
expect(xhr.send).toHaveBeenCalledWith(null);
|
|
123
|
-
});
|
|
124
|
-
test('should send the body when provided', () => {
|
|
125
|
-
const body = faker.lorem.paragraph();
|
|
126
|
-
submitData.xhr({
|
|
127
|
-
url,
|
|
128
|
-
body
|
|
129
|
-
});
|
|
130
|
-
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0];
|
|
131
|
-
expect(xhr.send).toHaveBeenCalledWith(body);
|
|
132
|
-
});
|
|
133
|
-
test('should set async to false', () => {
|
|
134
|
-
submitData.xhr({
|
|
135
|
-
url,
|
|
136
|
-
sync: true
|
|
137
|
-
});
|
|
138
|
-
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0];
|
|
139
|
-
expect(xhr.open).toHaveBeenCalledWith('POST', url, false);
|
|
140
|
-
});
|
|
141
|
-
test('should use the provided method', () => {
|
|
142
|
-
submitData.xhr({
|
|
143
|
-
url,
|
|
144
|
-
method: 'HEAD'
|
|
145
|
-
});
|
|
146
|
-
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0];
|
|
147
|
-
expect(xhr.open).toHaveBeenCalledWith('HEAD', url, true);
|
|
148
|
-
});
|
|
149
|
-
test('should use the provided headers', () => {
|
|
150
|
-
const headers = [{
|
|
151
|
-
key: faker.lorem.word(),
|
|
152
|
-
value: faker.datatype.uuid()
|
|
153
|
-
}];
|
|
154
|
-
submitData.xhr({
|
|
155
|
-
url,
|
|
156
|
-
headers
|
|
157
|
-
});
|
|
158
|
-
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0];
|
|
159
|
-
expect(xhr.setRequestHeader).not.toHaveBeenCalledWith('content-type', 'text/plain');
|
|
160
|
-
expect(xhr.setRequestHeader).toHaveBeenCalledWith(headers[0].key, headers[0].value);
|
|
161
|
-
});
|
|
162
|
-
test('should not throw an error if withCredentials is not supported', () => {
|
|
163
|
-
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
164
|
-
this.prototype = XMLHttpRequest.prototype;
|
|
165
|
-
this.open = jest.fn();
|
|
166
|
-
this.send = jest.fn();
|
|
167
|
-
this.setRequestHeader = jest.fn();
|
|
168
|
-
});
|
|
169
|
-
expect(() => submitData.xhr({
|
|
170
|
-
url
|
|
171
|
-
})).not.toThrow();
|
|
172
|
-
});
|
|
173
|
-
test('should not throw an error if setRequestHeader throws an error', () => {
|
|
174
|
-
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
175
|
-
this.prototype = XMLHttpRequest.prototype;
|
|
176
|
-
this.open = jest.fn();
|
|
177
|
-
this.send = jest.fn();
|
|
178
|
-
this.setRequestHeader = jest.fn();
|
|
179
|
-
Object.defineProperty(this, 'withCredentials', {
|
|
180
|
-
get: jest.fn().mockImplementation(() => {
|
|
181
|
-
throw new Error(faker.lorem.sentence());
|
|
182
|
-
}),
|
|
183
|
-
set: jest.fn().mockImplementation(() => {
|
|
184
|
-
throw new Error(faker.lorem.sentence());
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
expect(() => submitData.xhr({
|
|
189
|
-
url
|
|
190
|
-
})).not.toThrow();
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
describe('submitData.img', () => {
|
|
194
|
-
test('should return an HTMLImageElement', () => {
|
|
195
|
-
const imageUrl = 'https://example.com/image.png';
|
|
196
|
-
const result = submitData.img({
|
|
197
|
-
url: imageUrl
|
|
198
|
-
});
|
|
199
|
-
expect(result).toBeInstanceOf(HTMLImageElement);
|
|
200
|
-
expect(result.src).toBe(imageUrl);
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
describe('submitData.beacon', () => {
|
|
204
|
-
afterEach(() => {
|
|
205
|
-
delete window.navigator.sendBeacon;
|
|
206
|
-
});
|
|
207
|
-
test('should return true when beacon request succeeds', () => {
|
|
208
|
-
window.navigator.sendBeacon = jest.fn().mockReturnValue(true);
|
|
209
|
-
const body = faker.lorem.paragraph();
|
|
210
|
-
const result = submitData.beacon({
|
|
211
|
-
url,
|
|
212
|
-
body
|
|
213
|
-
});
|
|
214
|
-
expect(result).toBe(true);
|
|
215
|
-
expect(window.navigator.sendBeacon).toHaveBeenCalledWith(url, body);
|
|
216
|
-
});
|
|
217
|
-
test('should return false when beacon request returns false', () => {
|
|
218
|
-
window.navigator.sendBeacon = jest.fn().mockReturnValue(false);
|
|
219
|
-
const result = submitData.beacon({
|
|
220
|
-
url
|
|
221
|
-
});
|
|
222
|
-
expect(result).toBe(false);
|
|
223
|
-
});
|
|
224
|
-
test('should return false when beacon request throws an error', () => {
|
|
225
|
-
window.navigator.sendBeacon = jest.fn(() => {
|
|
226
|
-
throw new Error(faker.lorem.sentence());
|
|
227
|
-
});
|
|
228
|
-
const result = submitData.beacon({
|
|
229
|
-
url
|
|
230
|
-
});
|
|
231
|
-
expect(result).toBe(false);
|
|
232
|
-
});
|
|
233
|
-
test('should always bind window.navigator to the sendBeacon function', () => {
|
|
234
|
-
window.navigator.sendBeacon = jest.fn().mockReturnValue(true);
|
|
235
|
-
window.navigator.sendBeacon.bind = jest.fn(() => {});
|
|
236
|
-
submitData.beacon({
|
|
237
|
-
url
|
|
238
|
-
});
|
|
239
|
-
expect(window.navigator.sendBeacon.bind).toHaveBeenCalledWith(window.navigator);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { applyFnToProps } from './traverse';
|
|
2
|
-
test.each(['not an object', null, undefined])('should return input unchanged when input is %p', input => {
|
|
3
|
-
const result = applyFnToProps(input, jest.fn());
|
|
4
|
-
expect(result).toEqual(input);
|
|
5
|
-
});
|
|
6
|
-
test('should apply the provided function only to properties of the specified type', () => {
|
|
7
|
-
const obj = {
|
|
8
|
-
stringProp: 'Hello',
|
|
9
|
-
numberProp: 42,
|
|
10
|
-
arrayProp: [1, 2, 3],
|
|
11
|
-
objectProp: {
|
|
12
|
-
foo: 'bar'
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const fn = jest.fn(value => value.toUpperCase());
|
|
16
|
-
const result = applyFnToProps(obj, fn, 'string');
|
|
17
|
-
expect(result.stringProp).toBe('HELLO');
|
|
18
|
-
expect(result.numberProp).toBe(42);
|
|
19
|
-
expect(result.arrayProp).toEqual([1, 2, 3]);
|
|
20
|
-
expect(result.objectProp).toEqual({
|
|
21
|
-
foo: 'BAR'
|
|
22
|
-
});
|
|
23
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
24
|
-
expect(fn).toHaveBeenCalledWith('Hello');
|
|
25
|
-
expect(fn).toHaveBeenCalledWith('bar');
|
|
26
|
-
});
|
|
27
|
-
test('should ignore properties specified in ignoreKeys', () => {
|
|
28
|
-
const obj = {
|
|
29
|
-
a: 1,
|
|
30
|
-
b: 2,
|
|
31
|
-
c: 3
|
|
32
|
-
};
|
|
33
|
-
const fn = jest.fn(value => value + 1);
|
|
34
|
-
const ignoreKeys = ['c'];
|
|
35
|
-
const result = applyFnToProps(obj, fn, 'number', ignoreKeys);
|
|
36
|
-
expect(result.a).toBe(2);
|
|
37
|
-
expect(result.b).toBe(3);
|
|
38
|
-
expect(result.c).toBe(3);
|
|
39
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
40
|
-
expect(fn).toHaveBeenCalledWith(1);
|
|
41
|
-
expect(fn).toHaveBeenCalledWith(2);
|
|
42
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { faker } from '@faker-js/faker';
|
|
2
|
-
import { globalScope } from '../util/global-scope';
|
|
3
|
-
import { originals } from '../config/config';
|
|
4
|
-
jest.mock('./wrap-function', () => ({
|
|
5
|
-
__esModule: true,
|
|
6
|
-
createWrapperWithEmitter: jest.fn(() => fn => function () {
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
10
|
-
return fn.apply(null, args);
|
|
11
|
-
})
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('../event-emitter/contextual-ee', () => ({
|
|
14
|
-
__esModule: true,
|
|
15
|
-
getOrSetContext: jest.fn(() => ({})),
|
|
16
|
-
ee: {
|
|
17
|
-
get: jest.fn(name => ({
|
|
18
|
-
debugId: name,
|
|
19
|
-
on: jest.fn(),
|
|
20
|
-
context: jest.fn(() => ({})),
|
|
21
|
-
emit: jest.fn()
|
|
22
|
-
}))
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
jest.mock('../config/config', () => ({
|
|
26
|
-
__esModule: true,
|
|
27
|
-
originals: {}
|
|
28
|
-
}));
|
|
29
|
-
jest.mock('../util/global-scope', () => ({
|
|
30
|
-
__esModule: true,
|
|
31
|
-
globalScope: {
|
|
32
|
-
NREUM: {}
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
let promiseConstructorCalls;
|
|
36
|
-
beforeEach(async () => {
|
|
37
|
-
promiseConstructorCalls = [];
|
|
38
|
-
|
|
39
|
-
// Proxy the global Promise to prevent the wrapping from
|
|
40
|
-
// messing with Jest internal promises
|
|
41
|
-
originals.PR = new Proxy(class extends Promise {}, {
|
|
42
|
-
construct(target, args) {
|
|
43
|
-
promiseConstructorCalls.push(args);
|
|
44
|
-
return Reflect.construct(target, args);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
(await import('./wrap-promise')).wrapPromise();
|
|
48
|
-
});
|
|
49
|
-
afterEach(() => {
|
|
50
|
-
jest.resetModules();
|
|
51
|
-
});
|
|
52
|
-
test('should wrap promise constructor', async () => {
|
|
53
|
-
const promiseInstance = new globalScope.Promise(jest.fn());
|
|
54
|
-
expect(promiseInstance).toBeInstanceOf(Promise);
|
|
55
|
-
expect(promiseConstructorCalls.length).toEqual(1);
|
|
56
|
-
expect(globalScope.Promise.toString()).toMatch(/\[native code\]/);
|
|
57
|
-
expect(globalScope.Promise.name).toEqual('Promise');
|
|
58
|
-
});
|
|
59
|
-
describe('all', () => {
|
|
60
|
-
test('should work with acceptable iterables', async () => {
|
|
61
|
-
const resolveValue = faker.datatype.uuid();
|
|
62
|
-
const customIterable = new CustomIterable([new globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
63
|
-
const arrayIterable = [new globalScope.Promise(resolve => resolve(resolveValue))];
|
|
64
|
-
const setIterable = new Set();
|
|
65
|
-
setIterable.add(new globalScope.Promise(resolve => resolve(resolveValue)));
|
|
66
|
-
await expect(globalScope.Promise.all(customIterable)).resolves.toEqual([resolveValue]);
|
|
67
|
-
await expect(globalScope.Promise.all(arrayIterable)).resolves.toEqual([resolveValue]);
|
|
68
|
-
await expect(globalScope.Promise.all(setIterable)).resolves.toEqual([resolveValue]);
|
|
69
|
-
});
|
|
70
|
-
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
71
|
-
jest.spyOn(globalScope.Promise, 'resolve');
|
|
72
|
-
await expect(globalScope.Promise.all(input)).rejects.toThrow();
|
|
73
|
-
expect(globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe('race', () => {
|
|
77
|
-
test('should work with acceptable iterables', async () => {
|
|
78
|
-
jest.spyOn(globalScope.Promise, 'resolve');
|
|
79
|
-
const resolveValue = faker.datatype.uuid();
|
|
80
|
-
const customIterable = new CustomIterable([new globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
81
|
-
const arrayIterable = [new globalScope.Promise(resolve => resolve(resolveValue))];
|
|
82
|
-
const setIterable = new Set();
|
|
83
|
-
setIterable.add(new globalScope.Promise(resolve => resolve(resolveValue)));
|
|
84
|
-
await expect(globalScope.Promise.race(customIterable)).resolves.toEqual(resolveValue);
|
|
85
|
-
await expect(globalScope.Promise.race(arrayIterable)).resolves.toEqual(resolveValue);
|
|
86
|
-
await expect(globalScope.Promise.race(setIterable)).resolves.toEqual(resolveValue);
|
|
87
|
-
expect(globalScope.Promise.resolve).toHaveBeenCalled();
|
|
88
|
-
});
|
|
89
|
-
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
90
|
-
jest.spyOn(globalScope.Promise, 'resolve');
|
|
91
|
-
await expect(globalScope.Promise.race(input)).rejects.toThrow();
|
|
92
|
-
expect(globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
class CustomIterable {
|
|
96
|
-
#iterables = [];
|
|
97
|
-
constructor(iterables) {
|
|
98
|
-
this.#iterables = iterables;
|
|
99
|
-
}
|
|
100
|
-
[Symbol.iterator]() {
|
|
101
|
-
return {
|
|
102
|
-
index: 0,
|
|
103
|
-
iterables: this.#iterables,
|
|
104
|
-
next() {
|
|
105
|
-
return {
|
|
106
|
-
done: this.index >= this.iterables.length,
|
|
107
|
-
value: this.iterables[this.index++] || undefined
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
[Symbol.iterator]() {
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { canonicalFunctionName } from './canonical-function-name';
|
|
2
|
-
test.each([{
|
|
3
|
-
input: null,
|
|
4
|
-
expected: undefined,
|
|
5
|
-
title: 'Return undefined if no function name'
|
|
6
|
-
}, {
|
|
7
|
-
input: 'test',
|
|
8
|
-
expected: 'test',
|
|
9
|
-
title: 'Simple function name'
|
|
10
|
-
}, {
|
|
11
|
-
input: 'scope1/scope2/func',
|
|
12
|
-
expected: 'func',
|
|
13
|
-
title: 'Remove Firefox scopes'
|
|
14
|
-
}, {
|
|
15
|
-
input: 'scope1.func',
|
|
16
|
-
expected: 'func',
|
|
17
|
-
title: 'Remove Chrome scopes'
|
|
18
|
-
}, {
|
|
19
|
-
input: '<anonymous>',
|
|
20
|
-
expected: undefined,
|
|
21
|
-
title: 'Return undefined ending is non-alphanumeric'
|
|
22
|
-
}])('$title', _ref => {
|
|
23
|
-
let {
|
|
24
|
-
input,
|
|
25
|
-
expected
|
|
26
|
-
} = _ref;
|
|
27
|
-
const result = canonicalFunctionName(input);
|
|
28
|
-
expect(result).toEqual(expected);
|
|
29
|
-
});
|