1 of 47

Old Apps,

New Tricks

�How AI can write Automated tests for your Shiny Apps

for

Python

2 of 47

3 of 47

Role:

QA Engineer, Shiny Team

  • Hunt bugs outside the code
  • Hunt bugs inside the code

Some things I to do:

  • Eat pizza

4 of 47

Meet Gregory the Grasshopper

5 of 47

introvert

6 of 47

7 of 47

One's a hermit, two's a trigger, three’s chaos

8 of 47

The trigger

Serotonin is released

9 of 47

10 of 47

11 of 47

Dangerous threats can lie dormant until a trigger awakens them

Dormant threat

Dormant threat

prevents

Dormant threat

Dormant threat

Dangerous threat

12 of 47

App

Test

Bug(s)

App

Bug(s)

13 of 47

State of testing in the Shiny ecosystem

Shiny for R

Shiny for Python

Shinytest2

Playwright

14 of 47

Shiny for R

Shinytest2

15 of 47

Shiny for Python

Playwright

16 of 47

Shiny for Python

Playwright

17 of 47

Shiny for Python

Playwright

18 of 47

Shiny for Python

2023

Introduced controllers

Make it easy to write Playwright tests

Introduced shiny add test CLI command

Automatically generate a boilerplate test file for a Shiny for Python app

2024

Enhanced shiny add test

Integrated AI with the CLI command to generate complete E2E test for a Shiny for Python app

2025

19 of 47

Playwright

controllers simplify component interaction within tests

YOU

controllers

components

20 of 47

Playwright

InputCheckbox controller

Methods:

  • expect_checked()
  • expect_label()
  • expect_width()
  • set()

controllers simplify component interaction within tests

21 of 47

Shiny for Python

2023

Introduced controllers

Make it easy to write Playwright tests

Introduced shiny add test CLI command

Automatically generate a boilerplate test file for a Shiny for Python app

2024

Enhanced shiny add test

Integrated AI with the CLI command to generate complete E2E test for a Shiny for Python app

2025

22 of 47

type command

Shiny for Python

How 2024 shiny add test worked

Select App file

Test file is created

type command

Select App file

23 of 47

How 2024 shiny add test worked

Test file is saved

test scaffolding

test_app.py

Shiny for Python

24 of 47

How 2024 shiny add test worked

Test file is saved

test_app.py

Shiny for Python

25 of 47

How 2024 shiny add test worked

Test file is saved

test_app.py

Shiny for Python

26 of 47

What 2024 shiny add test lacked

What we provided

What we wished we provided

What we provided

27 of 47

It's 2025 now

where we are surrounded by AI

28 of 47

Shiny for Python

2023

Introduced controllers

Make it easy to write Playwright tests

Introduced shiny add test CLI command

Automatically generate a boilerplate test file for a Shiny for Python app

2024

Enhanced shiny add test�CLI command

Integrated AI with the CLI command to generate complete E2E test for a Shiny for Python app

2025

29 of 47

How 2025 shiny add test works

30 of 47

How 2025 shiny add test works

31 of 47

off-the-shelf AI

32 of 47

shiny add test

33 of 47

off-the-shelf AI

34 of 47

shiny add test

35 of 47

off-the-shelf AI

36 of 47

shiny add test

37 of 47

HALLUCINATIONS!!!

Enter the of using AI

38 of 47

How we minimize hallucinations within shiny add test

We run 10 evaluation apps through shiny add test to generate tests

39 of 47

How we minimize hallucinations within shiny add test

Run all generated tests

Passing % > 85%

Evaluate tests through inspect-ai scorers

Passing % > 80%

Evaluate tests through inspect-ai scorers

Passing % > 80%

40 of 47

Show me the steps

type command

Enter path to Shiny app

Enter path for test file

41 of 47

DEMO

42 of 47

43 of 47

Some tips to get the most from your shiny add test experience

1. Use premium models from Anthropic or OpenAI for best results

44 of 47

Some tips to get the most from your shiny add test experience

2. The generated tests will only cover Shiny components — they won’t test third‑party APIs or databases.

1. Use premium models from Anthropic or OpenAI for best results

45 of 47

Some tips to get the most from your shiny add test experience

2. The generated tests will only cover Shiny components — they won’t test third‑party APIs or databases.

3. Use ids for every shiny component within your Shiny App

1. Use premium models from Anthropic or OpenAI for best results

46 of 47

Some tips to get the most from your shiny add test experience

2. The generated tests will only cover Shiny components — they won’t test third‑party APIs or databases.

3. Use ids for every shiny component within your Shiny App

1. Use premium models from Anthropic or OpenAI for best results

4. Use caution when sharing code with LLMs

47 of 47

Generate Shiny app tests with AI

Karan Gathani

/Shiny Team

@karangattu

  • Available on PyPI - shiny v1.5.0
  • Tests prevent regressions, ensure reliable user experience.
  • Generate tests easily by typing

shiny add test CLI command

  • Stop grasshoppers from getting too rowdy
  • Extend generated tests to include non-shiny business logic