vega-frontend-monorepo/apps/trading/e2e
m.ray 375f4da541
fix(trading): fix reward card asssets (#5888)
Co-authored-by: bwallacee <ben@vega.xyz>
2024-02-29 09:21:35 +00:00
..
actions chore(trading): fees e2e tests (#5496) 2023-12-19 12:22:15 +00:00
fixtures chore(trading): update vega-market-sim to use to 0.74.0-preview.2 (#5603) 2024-01-17 12:19:52 +00:00
tests fix(trading): fix reward card asssets (#5888) 2024-02-29 09:21:35 +00:00
.env chore(trading): update vega binaries (#5873) 2024-02-27 23:24:28 +00:00
.env.develop chore(trading): update vega binaries (#5873) 2024-02-27 23:24:28 +00:00
.env.main chore(trading): update vega version for sim tests - 0.74.0 (#5784) 2024-02-14 09:31:28 +00:00
config.py chore(trading): add playwright and market sim testing framework (#5199) 2023-11-14 10:05:07 -08:00
conftest.py chore(trading): revert reuse vega work (#5883) 2024-02-28 16:57:42 +00:00
poetry.lock chore(trading): update vega binaries (#5873) 2024-02-27 23:24:28 +00:00
pyproject.toml chore(trading): update vega-market-sim to use to 0.74.0-preview.2 (#5603) 2024-01-17 12:19:52 +00:00
README.md chore(trading): update e2e test readme (#5844) 2024-02-22 21:50:55 +01:00
wallet_config.py feat(trading): activity streaks, reward hoarder bonus and active rewards (#5491) 2024-01-05 11:16:59 +00:00

Trading Market-Sim End-To-End Tests

This directory contains end-to-end tests for the Trading application using Vega-market-sim. This guide will help you set up your environment and run the tests efficiently.

Prerequisites

Ensure you have the following installed:

Setup

1. Install Dependencies

2. Configure Your Environment

Ensure you're in the tests folder before executing commands.

poetry shell
poetry update vega-sim  # Updates to the latest version of the market-sim branch
poetry install
playwright install chromium  # Installs necessary browsers for Playwright

3. Prepare Binaries and Docker Images

Download necessary binaries for the desired Vega version:

python -m vega_sim.tools.load_binaries --force --version $VEGA_VERSION

Pull Docker images for your environment:

  • Development: docker pull vegaprotocol/trading:develop
  • Production: docker pull vegaprotocol/trading:main

4. Build a Docker Image of Your Locally Built Trading App

./docker/prepare-dist.sh
docker build -f docker/node-outside-docker.Dockerfile --build-arg APP=trading --build-arg ENV_NAME=stagnet1 -t vegaprotocol/trading:latest .

Running Tests

Ensure the Docker daemon is running. Update the .env file with the correct trading image before proceeding.

  • Run all tests: poetry run pytest

  • Run a specific test: poetry run pytest -k "test_name" -s --headed

  • Run tests using your locally served console:

    In one terminal window, build and serve the trading console:

    yarn nx build trading
    yarn nx serve trading
    

    Once the console is served, update the .env file to set local_server=true. You can then run your tests using the same commands as above. NOTE: Parallel running of tests will not work against locally served console.

Test Strategy and Container Cleanup

Strategy

We aim for each test file to use a single Vega instance to ensure test isolation and manage resources efficiently. This approach helps in maintaining test performance and reliability.

Cleanup Procedure

To ensure proper cleanup of containers after each test, use the following fixture pattern:

@pytest.fixture
def vega(request):
    with init_vega(request) as vega_instance:
        request.addfinalizer(lambda: cleanup_container(vega_instance))
        yield vega_instance

Running Tests in Parallel

For running tests in parallel:

  • Within the e2e folder: poetry run pytest -s --numprocesses auto --dist loadfile
  • From anywhere: yarn trading:test:all

Troubleshooting

If IntelliSense is not working in VSCode, follow these steps:

  1. Find the Poetry environment's Python binary: poetry run which python
  2. In VSCode, open the command menu (cmd + shift + p), search for Python: Select Interpreter, select Enter interpreter path, and paste the path from step 1.