Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mysticfall/kotlin-react-test
Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project.
https://github.com/mysticfall/kotlin-react-test
Last synced: about 2 months ago
JSON representation
Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project.
- Host: GitHub
- URL: https://github.com/mysticfall/kotlin-react-test
- Owner: mysticfall
- License: mit
- Created: 2021-10-16T11:31:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-01T17:36:00.000Z (almost 3 years ago)
- Last Synced: 2024-04-16T18:05:09.080Z (9 months ago)
- Language: Kotlin
- Size: 82 KB
- Stars: 10
- Watchers: 2
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Build](https://github.com/mysticfall/kotlin-react-test/workflows/publish-snapshot/badge.svg)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.mysticfall/kotlin-react-test)](https://mvnrepository.com/artifact/io.github.mysticfall/kotlin-react-test)# Kotlin API for React Test Renderer
Kotlin wrapper for [React Test Renderer](https://reactjs.org/docs/test-renderer.html),
which can be used to unit test React components in a Kotlin/JS project.## How to Use
### Installation
With Gradle (using Kotlin DSL):
```kotlin
implementation("io.github.mysticfall:kotlin-react-test:1.2.0")
```Alternatively, using Groovy DSL:
```groovy
implementation "io.github.mysticfall:kotlin-react-test:1.2.0"
```### Code Example
The most straightforward way of using the library is to make your test class implement
`ReactTestSupport`, as shown below:```kotlin
import mysticfall.kotlin.react.test.ReactTestSupportclass ComponentTest : ReactTestSupport {
@Test
fun testHeaderTitle() {
val renderer = render {
HeaderTitle {
attrs {
title = "Kotlin/JS"
}
}
}val title = renderer.root.findByType(HeaderTitle)
assertEquals("Kotlin/JS", title.props.title)
}
}
```The project itself has quite an extensive set of test cases, which can serve as examples that show
how various features of React Test Renderer can be used in Kotlin.## LICENSE
This project is provided under the terms of [MIT License](LICENSE).