Check Browser tests in korlibs-image
- Dominant language
- WebAssembly
- Stars
- 42
- Forks
- 11
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
Flaky test case in korlibs-image/src/commonTest/kotlin/korlibs/image/format/QOITest.kt
Solution
The failing test is qoiToOutputBitmapWidthMismatchNewBitmapReturnedInstead in the korlibs-image:jsBrowserTest task. The issue is that this test is flaky in the JavaScript/browser environment - it's executing successfully in the test suite but the browser test runner is crashing unexpectedly during execution.
Root Cause
The test at line 104-115 in QOITest.kt is attempting to decode a QOI image into a pre-allocated bitmap with mismatched dimensions. While the test logic itself is sound, the browser test environment is experiencing a process crash.
Recommended Fix
The issue appears to be an environment-specific flakiness in the JavaScript browser test runner. Consider these solutions:
Add a timeout and error handling to make the test more robust in browser environments:
``` Kotlin
@Test
fun qoiToOutputBitmapWidthMismatchNewBitmapReturnedInstead() = suspendTestNoBrowser {
RegisteredImageFormats.register(PNG)
val qoiOutBitmap = Bitmap32(666, 600, premultiplied = false)
val qoiBytes = resourcesVfs["dice.qoi"].readBytes()
try {
val output = withTimeoutOrNull(5000) {
QOI.decode(qoiBytes, ImageDecodingProps.DEFAULT.copy(out = qoiOutBitmap))
} ?: fail("QOI decode timed out")
assertNotSame(qoiOutBitmap, output)
} catch (e: Exception) {
fail("Test failed with exception: ${e.message}")
}
}
```
Mark the test as non-browser if it's not essential for browser testing:
``` Kotlin
@Test
fun qoiToOutputBitmapWidthMismatchNewBitmapReturnedInstead() = suspendTestNoBrowser {
// This uses suspendTestNoBrowser which should skip in browser environments
// Ensure this annotation is properly respected in your test configuration
}
```
Check the build configuration in your Gradle setup to ensure browser test timeouts are appropriately configured for image processing tasks, which can be resource-intensive in JavaScript environments.
The test is already using suspendTestNoBrowser, which should prevent it from running in browsers, but verify your test runner configuration is properly respecting this annotation
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with korlibs-image/src/commonTest/kotlin/korlibs/image/format/QOITest.kt, especially lines 104-115 and qoiToOutputBitmapWidthMismatchNewBitmapReturnedInstead. Run the korlibs-image:jsBrowserTest task and inspect how suspendTestNoBrowser is handled in the browser test configuration. Done means the browser test no longer crashes while preserving the intended mismatched-dimension assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100