Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)
}
}
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Loading