From 6829b8221342ebd59afb76703acf1a2071094a8b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Mar 2026 17:10:26 -0400 Subject: [PATCH] Add parameterized surface test for all 6 RN components Co-Authored-By: Claude Sonnet 4.6 --- .../java/com/testapp/ComponentSurfaceTest.kt | 34 +++++++++++++++++++ index.js | 7 ++++ 2 files changed, 41 insertions(+) create mode 100644 android/app/src/androidTest/java/com/testapp/ComponentSurfaceTest.kt diff --git a/android/app/src/androidTest/java/com/testapp/ComponentSurfaceTest.kt b/android/app/src/androidTest/java/com/testapp/ComponentSurfaceTest.kt new file mode 100644 index 0000000..68f5750 --- /dev/null +++ b/android/app/src/androidTest/java/com/testapp/ComponentSurfaceTest.kt @@ -0,0 +1,34 @@ +package com.rnstorybookautoscreenshots + +import androidx.test.platform.app.InstrumentationRegistry +import com.testapp.MainApplication +import junit.framework.TestCase.assertNotNull +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +class ComponentSurfaceTest(private val componentName: String) { + + companion object { + @JvmStatic + @Parameterized.Parameters(name = "{0}") + fun components() = listOf( + arrayOf("MyFeature"), + arrayOf("SwitchFeature"), + arrayOf("TimerFeature"), + arrayOf("CoinFlipFeature"), + arrayOf("Button"), + arrayOf("Header"), + ) + } + + @Test + fun constructViewTest() { + val context = InstrumentationRegistry.getInstrumentation().targetContext + val app = context.applicationContext as MainApplication + val surface = app.reactHost.createSurface(context, componentName, null) + surface.start() + assertNotNull(surface.view) + } +} diff --git a/index.js b/index.js index 5741a9d..fbc1388 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,13 @@ const { configure, StoryRenderer } = require('rn-storybook-auto-screenshots'); configure(view); AppRegistry.registerComponent('StoryRenderer', () => StoryRenderer); +AppRegistry.registerComponent('MyFeature', () => require('./MyFeature').default); +AppRegistry.registerComponent('SwitchFeature', () => require('./SwitchFeature').default); +AppRegistry.registerComponent('TimerFeature', () => require('./TimerFeature').default); +AppRegistry.registerComponent('CoinFlipFeature', () => require('./CoinFlipFeature').default); +AppRegistry.registerComponent('Button', () => require('./.rnstorybook/stories/Button').Button); +AppRegistry.registerComponent('Header', () => require('./.rnstorybook/stories/Header').Header); + // Modes: 'app' | 'storybook' const MODE = 'app';