Skip to content

Commit

Permalink
chore: Update README and support test filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 4, 2023
1 parent a3565c7 commit a187161
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,46 @@ This project is built using `turborepo`. The above commands are just aliases to
yarn dev --filter=create-lz-oapp...
```

### Running tests

The tests are by default executed in a containerized environment that sets up two `hardhat` nodes accessible from within the environment:

- `http://network-britney:8545`
- `http://network-vengaboys:8545`

You can run the whole test suite within this environment by running:

```bash
yarn test
```

#### Refining tested packages

To only run a specific test suite, you can define `DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS` environment variable before running the tests. This variable will be passed to the underlying `turbo` command and can contain any arguments that this command understands, for example:

```bash
# To only run tests for @layerzerolabs/ua-utils-evm-hardhat-test package
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-utils-evm-hardhat-test yarn test
```

#### Rebuilding containers

`docker compose` will by default reuse images for containers it has already built. If by any chance you are seeing code changes not being reflected in your test runs, you can force docker to rebuild the images by defining `DOCKER_COMPOSE_RUN_TESTS_ARGS` environment variable. This variable will be passed to the underlying `docker compose run` command and can contain any arguments that this command understands, for example:

```bash
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test
```

#### Container logs

To monitor the container logs you'll need to run:

```bash
docker compose logs -f
```

This allows you to monitor logs coming from e.g. the `hardhat` nodes

### Troubleshooting

#### Problems with committing
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ services:
condition: service_healthy
volumes:
- ./packages:/app/packages
command: ["npx", "turbo", "test"]
command: "npx turbo test $DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS"
31 changes: 2 additions & 29 deletions packages/ua-utils-evm-hardhat-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,6 @@

## Development

This package provides integration tests for `@layerzerolabs/utils-evm-hardhat` executed within a containerized setup. To run the test suite, simply run:
This package provides integration tests for `@layerzerolabs/utils-evm-hardhat` executed within a containerized setup. These tests are dependent on two networks that are bootstrapped in the root `docker-compose.yaml` and will only run when executed within that environment.

```bash
# You can use the alias command from this package directory
yarn test

# Or use turbo and run from project root
yarn test --filter=utils-evm-hardhat-test

# Or just use the actual test command from this package directory
docker compose run --rm tests
```

In case you're running the tests from the project root, it might sometimes be useful to rebuild the containers
(for example when adding/removing dependencies) and as a lazy developer, you might not be happy about `cd`ing to the package directory
and run the command from there. For that usecase the `$DOCKER_COMPOSE_RUN_TESTS_ARGS` environment variable has been added:

```bash
# To rebuild the containers before running tests from the project root
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test --filter=utils-evm-hardhat-test
```

To monitor the container logs, you'll need to `cd` into the package directory and run:

```bash
docker compose logs -f
```

This allows you to see any logs coming from the containers, including detailed logs from the `hardhat` nodes
.
Please see the root [`README.md`](../../README.md) for more information.

0 comments on commit a187161

Please sign in to comment.