Skip to content

Quick Start

Overview

This page takes one test through a silent run, a narrated run, and a render. The test answers its own requests, so it needs no server.

Run A Test

  1. Add the plugin to the root conftest.py.

    conftest.py
    pytest_plugins = ['limelight.pytest_plugin']
    
  2. Copy this test into your project.

    examples/test_order_approval.py
    from __future__ import annotations
    
    from typing import TYPE_CHECKING
    
    from playwright.sync_api import expect
    
    from limelight import Demo, StaticApplication
    
    if TYPE_CHECKING:
        from playwright.sync_api import Page, Route
    
    
    BASE_URL = 'http://shop.example.com'
    
    PAGE_HTML = """
    <html><body>
    <h1>Order SHOP-214</h1>
    <button onclick="this.textContent = 'Approved'">Approve</button>
    </body></html>
    """
    
    
    def order_serve(route: Route) -> None:
        route.fulfill(body=PAGE_HTML, content_type='text/html')
    
    
    def test_order_approval_demo(page: Page) -> None:
        page.route(f'{BASE_URL}/**', order_serve)
    
        application = StaticApplication(base_url=BASE_URL)
        demo = Demo(page, application, name='order-approval')
    
        demo.goto('/orders/SHOP-214')
        demo.title('Order Approval', subtitle='Draft to approved.')
        demo.narrate('Approve the order', body='Riley Chen signs off on SHOP-214.')
        demo.click(page.get_by_role('button', name='Approve'))
    
        expect(page.get_by_role('button', name='Approved')).to_be_visible()
    
  3. Run it silent. A silent run has no holds and writes nothing.

    pytest -k order_approval_demo
    
  4. Run it narrated. The --headed flag opens the window, because DEMO_MODE does not open one on its own.

    DEMO_MODE=narrate pytest -k order_approval_demo --headed
    
  5. Render a video. The render needs ffmpeg.

    DEMO_MODE=narrate DEMO_VIDEO=1 pytest -k order_approval_demo
    limelight-render .demos/order-approval --title "Order Approval" --subtitles
    

A narrated run writes to .demos/order-approval/, relative to the directory you ran it from. The name argument of the Demo names that directory.

The plugin fails a test whose page logs a console.error or throws an uncaught exception. The Configuration page shows how to allow one.