Skip to content


Zapy files can be imported directly in your tests to perform assertions.

Request test hook

Under each zapy file, it's possible to implement multiple tests under a unittest.TestCase class.

For example

# test hook expects a unittest.TestCase class, cannot be async
import unittest

class TestResponse(unittest.TestCase):
    def test_status_code(self):
        self.assertEqual(self.response.status_code, 200)

Integration test libraries

You can use any testing tool that support asynchronous for your tests.


Example using pytest with the extension pytest-asyncio.

import pytest
from zapy import requests
import glob

async def test_single(zapy_path):
    request = requests.from_path("request1.zapy")
    response = await request.send()

@pytest.mark.parametrize("zapy_path", glob.glob("my_requests/*.zapy"))
async def test_parameterized(zapy_path):
    request = requests.from_path(zapy_path)
    response = await request.send()


Example of a mixed scenario using pytest-playwright.

import pytest
import re
from playwright.async_api import async_playwright, expect
from zapy import requests

async def test_has_title():
    async with async_playwright() as p:
        browser = await p.webkit.launch()
        page = await browser.new_page()
        await page.goto("")

        # Expect a title "to contain" a substring.
        await expect(page).to_have_title(re.compile("Playwright"))
    request = requests.from_path('request1.zapy')
    response = await request.send()
    assert response.status_code == 200


You can implement your favorite CI/CD tool that runs python.

For example:

  • Jenkins
  • Travis CI
  • GitLab CI/CD

Read their documentation to run python unittest or pytest.