is there any way to have `StableIdents.getStableId...
# kotest
s
is there any way to have
StableIdents.getStableIdentifier(Any?)
be re-exposed so that it can be used? I was using it for the kotlin/js platform because I could not use
withData()
, as it would result in an error saying "Nested tests are not supported". my workaround for this was to instead use
withClue()
on the kotlin/js platform, doing this:
Copy code
actual fun FunSpecRootScope.testPrecomputed(
    context: String,
    precomputed: List<FuzzyTestData>,
    resultFunction: (String, String) -> Double,
) {
    context(context) {
        precomputed.forEach {
            withClue({ getStableIdentifier(it) }) {
                resultFunction(it.first, it.second) shouldBe (it.result plusOrMinus DEFAULT_TOLERANCE)
            }
        }
    }
}
in kotest 6.0.0, this would instead be changed to use
StableIdents.getStableIdentifier(it)
, however this does not work because
StableIdents
is
internal
. I was told previously that nested tests would be present in 6.0, however they don't seem to be.
a
I don't see why not. IMO we can make it
public
without much effort. WDYT @sam?
s
it would also be very helpful for anyone implementing their own custom test specs, as currently the
withData()
function is defined per-style, so if you defined your own style you wouldn't be able to use it
s
We're about to move withData to be generic
so it's not per style
s
I'd still want access to
StableIdents.getStableIdentifier(Any?)
, as currently nested tests do not work on kotlin/js, so I need to use
withClue()
which does not compute the stable identifier
👍🏼 1
a
I got it
@solonovamax here you go; https://github.com/kotest/kotest/pull/5126/files feel free to add the needed info to the docs, then it should be ready to go
s
I don't think it really needs to be documented and can be left as "semi-internal" ("it's used internally and is exposed for others to use, but isn't exactly documented and you just have to figure it out on your own")
s
I'm happy with that
a
I'll add some docs and mark the PR as ready. Help/suggestions on exact verbiage would be appreciated