Browse Source

ref(ts): Remove usage of `TestStubs.Frame` (#62276)

- replace `TestStubs` reference with an import
- add correct fixture for `ExceptionValue`

https://github.com/getsentry/frontend-tsc/issues/49
George Gritsouk 1 year ago
parent
commit
0becf714d5

+ 16 - 0
fixtures/js-stubs/exceptionValue.tsx

@@ -0,0 +1,16 @@
+import type {ExceptionValue as ExceptionValueType} from 'sentry/types';
+
+export function ExceptionValue(
+  props: Partial<ExceptionValueType> = {}
+): ExceptionValueType {
+  return {
+    mechanism: null,
+    rawStacktrace: null,
+    stacktrace: null,
+    threadId: null,
+    type: 'BadError',
+    value: 'message',
+    module: null,
+    ...props,
+  };
+}

+ 10 - 7
static/app/components/events/interfaces/crashContent/stackTrace/rawContent.spec.tsx

@@ -1,3 +1,6 @@
+import {ExceptionValue as ExceptionValueFixture} from 'sentry-fixture/exceptionValue';
+import {Frame as FrameFixture} from 'sentry-fixture/frame';
+
 import displayRawContent, {
 import displayRawContent, {
   getJavaFrame,
   getJavaFrame,
   getJavaPreamble,
   getJavaPreamble,
@@ -9,7 +12,7 @@ describe('RawStacktraceContent', function () {
     it('should render java frames', function () {
     it('should render java frames', function () {
       expect(
       expect(
         getJavaFrame(
         getJavaFrame(
-          TestStubs.Frame({
+          FrameFixture({
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             function: 'run',
             function: 'run',
             filename: 'QueuedThreadPool.java',
             filename: 'QueuedThreadPool.java',
@@ -23,7 +26,7 @@ describe('RawStacktraceContent', function () {
       // without line number
       // without line number
       expect(
       expect(
         getJavaFrame(
         getJavaFrame(
-          TestStubs.Frame({
+          FrameFixture({
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             function: 'run',
             function: 'run',
             filename: 'QueuedThreadPool.java',
             filename: 'QueuedThreadPool.java',
@@ -36,7 +39,7 @@ describe('RawStacktraceContent', function () {
       // without line number and filename
       // without line number and filename
       expect(
       expect(
         getJavaFrame(
         getJavaFrame(
-          TestStubs.Frame({
+          FrameFixture({
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
             function: 'run',
             function: 'run',
             filename: 'QueuedThreadPool.java',
             filename: 'QueuedThreadPool.java',
@@ -52,7 +55,7 @@ describe('RawStacktraceContent', function () {
     it('takes a type and value', () => {
     it('takes a type and value', () => {
       expect(
       expect(
         getJavaPreamble(
         getJavaPreamble(
-          TestStubs.Frame({
+          ExceptionValueFixture({
             type: 'Baz',
             type: 'Baz',
             value: 'message',
             value: 'message',
             module: undefined,
             module: undefined,
@@ -64,7 +67,7 @@ describe('RawStacktraceContent', function () {
     it('takes a module name', () => {
     it('takes a module name', () => {
       expect(
       expect(
         getJavaPreamble(
         getJavaPreamble(
-          TestStubs.Frame({
+          ExceptionValueFixture({
             module: 'foo.bar',
             module: 'foo.bar',
             type: 'Baz',
             type: 'Baz',
             value: 'message',
             value: 'message',
@@ -86,14 +89,14 @@ describe('RawStacktraceContent', function () {
       framesOmitted: null,
       framesOmitted: null,
       registers: {},
       registers: {},
       frames: [
       frames: [
-        TestStubs.Frame({
+        FrameFixture({
           function: 'main',
           function: 'main',
           module: 'example.application',
           module: 'example.application',
           lineNo: 1,
           lineNo: 1,
           filename: 'application',
           filename: 'application',
           platform: undefined,
           platform: undefined,
         }),
         }),
-        TestStubs.Frame({
+        FrameFixture({
           function: 'doThing',
           function: 'doThing',
           module: 'example.application',
           module: 'example.application',
           lineNo: 2,
           lineNo: 2,