Dash Testing - Percy Throws Error

Hi,

I’m trying to test my dash app and it all works perfectly except for one line that uses percy; in that case it gives me an assertion error which it shouldn’t since everything is working fine. Would appreciate any tips!

If I run it without that line - the assert dash_duo.percy_snapshot(“testidgoeshere”) one in the code below - the test functions perfectly, loads the webdriver etc etc.

This is my test file code:

from dash.testing.application_runners import import_app


def test_bbaaa001(dash_duo):

    app = import_app("dash_test.app")
    dash_duo.start_server(app)

    dash_duo.wait_for_text_to_equal("h1", "About", timeout=10)

    assert dash_duo.find_element("em").text == "Sources"

    assert dash_duo.get_logs() == [], "Browser console should contain no error"

    assert dash_duo.percy_snapshot("bbaaa001-layout")

    return None

It’s in a directory called dash_test and I’m running it from my project root directory with the command

python -m pytest dash_test/

The dash_test directory also contains my app.py file and a conftest.py file. As specified in the dash testing documentation it just contains this function:

from selenium.webdriver.chrome.options import Options


def pytest_setup_options():
    options = Options()
    options.add_argument("--disable-gpu")
    return options

Here is the full output I’m getting after running the test with the percy snapshot line in it.

--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
Dash is running on http://127.0.0.1:8050/

 Warning: This is a development server. Do not use app.run_server
 in production, use a production WSGI server like gunicorn instead.

 * Serving Flask app "dash_test.app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO     dash_test.app:dash.py:1607 Dash is running on http://127.0.0.1:8050/

INFO     dash_test.app:dash.py:1608  Warning: This is a development server. Do not use app.run_server
INFO     dash_test.app:dash.py:1611  in production, use a production WSGI server like gunicorn instead.

INFO     werkzeug:_internal.py:113  * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET / HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET / HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_reload-hash HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_renderer/react@16.v1_5_1m1593111715.13.0.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_renderer/polyfill@7.v1_5_1m1593111715.8.7.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_renderer/prop-types@15.v1_5_1m1593111715.7.2.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_renderer/react-dom@16.v1_5_1m1593111715.13.0.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_core_components/dash_core_components.v1_10_1m1592438756.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_core_components/dash_core_components-shared.v1_10_1m1592438756.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_html_components/dash_html_components.v1_0_3m1585775459.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:08] "GET /_dash-component-suites/dash_renderer/dash_renderer.v1_5_1m1593111738.min.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:09] "GET /_dash-dependencies HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:09] "GET /_favicon.ico?v=1.13.4 HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:11] "GET /_reload-hash HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:11] "GET /_reload-hash HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:12] "GET /_dash-layout HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:12] "POST /_dash-update-component HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:12] "GET /_dash-component-suites/dash_core_components/async-markdown.v1_10_1m1592438751.js HTTP/1.1" 200 -
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:12] "GET /_dash-component-suites/dash_core_components/async-highlight.v1_10_1m1592438751.js HTTP/1.1" 200 -
-------------------------------------------------------------------------- Captured log teardown ---------------------------------------------------------------------------
INFO     werkzeug:_internal.py:113 127.0.0.1 - - [19/Aug/2020 19:49:13] "GET /_stop-ba37a96d8c184e548426a37722569791 HTTP/1.1" 200 -
========================================================================= short test summary info ==========================================================================
FAILED dash_test/test_one.py::test_bbaaa001 - AssertionError: assert None
============================================================================ 1 failed in 11.99s ============================================================================