Skip to content

Commit

Permalink
🚧 Make sure to fail the tests if a snapshot is missing (LayerZero-Lab…
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 26, 2024
1 parent c142d55 commit 694e1c1
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 16 deletions.
27 changes: 22 additions & 5 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<h1 align="center">Development</h1>

<p align="center">
<a href="#troubleshooting" style="color: #a77dff">Troubleshooting</a>
</p>

## Code layout

The code is arranged into:
Expand All @@ -28,13 +32,14 @@ This repository contains several git submodules. To clone the repository, please
# 1. Clone the repository

# Using HTTPS
git clone https://github.com/LayerZero-Labs/devtools.git
git clone --recurse-submodules https://github.com/LayerZero-Labs/devtools.git

# Using SSH
git clone [email protected]:LayerZero-Labs/devtools.git
git clone --recurse-submodules [email protected]:LayerZero-Labs/devtools.git

# 2. Install submodules
# 1A. Install submodules

# If you cloned the repository without the --recurse-submodules flag, you can install the required submodules by running
git submodule update --init
```

Expand Down Expand Up @@ -146,6 +151,18 @@ You can also pass additional arguments to the individual `test` scripts this way
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS="--filter=ua-devtools-evm-hardhat-test -- wire.test" pnpm test:ci
```

#### Updating snapshots

By default, `jest` will run in [CI mode](https://jestjs.io/docs/cli#--ci). This means that no new snapshots will be generated by default and `jest` will fail instead. This is important since we want to make sure that there are no missing snapshots when we merge to `main` branch.

To update the snapshots, you will need to run the tests in local mode (so that the new snapshots are written to your filesystem) and pass the [`--updateSnapshot`](https://jestjs.io/docs/cli#--updatesnapshot) CLI flag to `jest`:

```bash
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS="-- --updateSnapshot" pnpm test:local
```

If you encounter any errors coming from existing snapshots that have to do with output formatting (i.e. difference in colored/uncolored output), see the [troubleshooting section below](#troubleshooting--updating-snapshots)

#### Container logs

To monitor the container logs you'll need to run:
Expand Down Expand Up @@ -250,7 +267,7 @@ Don't forget to reset the `registry` NPM configuration once done:
pnpm config set registry https://registry.npmjs.org/
```

### Troubleshooting
### Troubleshooting <a id="troubleshooting"></a>

#### Problems with committing

Expand Down Expand Up @@ -292,7 +309,7 @@ If you encounter errors when running these tests, just set the environment varia
CI=1 pnpm test
```

#### Problems with snapshot updating
#### Problems with snapshot updating <a id="troubleshooting--updating-snapshots"></a>

If snapshots are used in a test that relies on filesystem paths, the situation becomes a bit complex. In long term, we should steer away from this approach as it makes updating snapshots a bit cumbersome.

Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"start": "./cli.js",
"test": "jest"
"test": "jest --ci"
},
"dependencies": {
"yoga-layout-prebuilt": "^1.10.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-evm-hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest --forceExit"
"test": "jest --ci --forceExit"
},
"dependencies": {
"micro-memoize": "~4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"dependencies": {
"p-memoize": "~4.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest --forceExit"
"test": "jest --ci --forceExit"
},
"devDependencies": {
"@layerzerolabs/io-devtools": "~0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/io-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"dependencies": {
"cli-table3": "^0.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"dependencies": {
"p-memoize": "~4.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"devDependencies": {
"@layerzerolabs/devtools": "~0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/ua-devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"clean": "rm -rf dist",
"dev": "$npm_execpath tsup --watch",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"dependencies": {
"p-memoize": "~4.0.4"
Expand Down
2 changes: 1 addition & 1 deletion tests/devtools-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rm -rf artifacts cache deployments",
"compile": "$npm_execpath hardhat compile",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest --runInBand --forceExit"
"test": "jest --ci --runInBand --forceExit"
},
"devDependencies": {
"@babel/core": "^7.23.7",
Expand Down
2 changes: 1 addition & 1 deletion tests/devtools-evm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rm -rf artifacts cache",
"compile": "$npm_execpath hardhat compile",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest"
"test": "jest --ci"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/ua-devtools-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rm -rf artifacts cache deployments",
"compile": "$npm_execpath hardhat compile",
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'",
"test": "jest --runInBand --forceExit"
"test": "jest --ci --runInBand --forceExit"
},
"devDependencies": {
"@babel/core": "^7.23.7",
Expand Down

0 comments on commit 694e1c1

Please sign in to comment.