GithubHelp home page GithubHelp logo

Comments (8)

chrisbanes avatar chrisbanes commented on June 13, 2024 1

Interesting! onDecomposeError = null seems like a good way to disable this.

For now I've just moved over to using Android unit tests instead. We were only really using the JVM target for testing anyway, so this feels like the best target to test on anyway.

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

Thanks for the question. Which platform is this?

from decompose.

chrisbanes avatar chrisbanes commented on June 13, 2024

JVM, but it doesn’t really matter what platform is used as the tests won’t be using the platform Main dispatcher (on purpose).

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

I will check, thanks.

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

I think I could add an API to disable main thread checks. Though this should be only happening on JVM/Desktop targets with extensions-compose-jetbrains module added as a dependency.
On iOS tests are running on the main thread, so as long as you are using only UnconfinedTestDispatcher - it should work.
On Android with JUnit - the checks are disabled because Looper is unavailable. Only instrumented tests may be affected, but I would prefer using real dispatchers with instrumented/integration tests.

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

I think the reason I didn't catch this earlier in the TodoApp sample is because it has a separate compose-ui module for Compose UI, and all components with their tests are in separate modules without extensions-compose-jetbrains. For the UI we could write simple screenshot tests, but this is another story.
Thanks for raising!

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

Btw, I have just realised that you can disable throwing this error as follows:

import com.arkivanov.decompose.errorhandler.onDecomposeError

@Before
fun before {
    onDecomposeError = null
}

WDYT? It might be still useful to have a dedicated API for disabling main thread checks.

from decompose.

arkivanov avatar arkivanov commented on June 13, 2024

It appears that those exceptions are just logs, they do not fail tests. As mentioned in the docs, the navigation is thread safe, but it's advised to navigate only on the main thread. There are checks that print error logs when access on a non-main thread is detected.

As suggested, we can use onDecomposeError = {} to disable error logs in tests. This can also be used to hook to an analytics/telemetry logging system.

Closing this for now. Feel free to reopen if there are any questions or concerns.

from decompose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.