From 694e1c1f5d8614e142e5fecd88cc97a6a25e2bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jakub=20Nani=C5=A1ta?= Date: Fri, 26 Jan 2024 09:26:35 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Make=20sure=20to=20fail=20the=20?= =?UTF-8?q?tests=20if=20a=20snapshot=20is=20missing=20(#255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DEVELOPMENT.md | 27 +++++++++++++++---- packages/create-lz-oapp/package.json | 2 +- packages/devtools-evm-hardhat/package.json | 2 +- packages/devtools-evm/package.json | 2 +- packages/devtools/package.json | 2 +- packages/io-devtools/package.json | 2 +- packages/protocol-devtools-evm/package.json | 2 +- packages/protocol-devtools/package.json | 2 +- packages/ua-devtools-evm/package.json | 2 +- tests/devtools-evm-hardhat-test/package.json | 2 +- tests/devtools-evm-test/package.json | 2 +- .../ua-devtools-evm-hardhat-test/package.json | 2 +- 12 files changed, 33 insertions(+), 16 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 6221937b1..2ddff7d15 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -10,6 +10,10 @@

Development

+

+ Troubleshooting +

+ ## Code layout The code is arranged into: @@ -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 git@github.com:LayerZero-Labs/devtools.git +git clone --recurse-submodules git@github.com: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 ``` @@ -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: @@ -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 #### Problems with committing @@ -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 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. diff --git a/packages/create-lz-oapp/package.json b/packages/create-lz-oapp/package.json index 4555f0a8a..dee27c799 100644 --- a/packages/create-lz-oapp/package.json +++ b/packages/create-lz-oapp/package.json @@ -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" diff --git a/packages/devtools-evm-hardhat/package.json b/packages/devtools-evm-hardhat/package.json index 5aea0d76b..4f683f043 100644 --- a/packages/devtools-evm-hardhat/package.json +++ b/packages/devtools-evm-hardhat/package.json @@ -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", diff --git a/packages/devtools-evm/package.json b/packages/devtools-evm/package.json index 27d455da0..5239d017f 100644 --- a/packages/devtools-evm/package.json +++ b/packages/devtools-evm/package.json @@ -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" diff --git a/packages/devtools/package.json b/packages/devtools/package.json index 6ca564550..77a019663 100644 --- a/packages/devtools/package.json +++ b/packages/devtools/package.json @@ -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", diff --git a/packages/io-devtools/package.json b/packages/io-devtools/package.json index f7b12c17f..2449d4a55 100644 --- a/packages/io-devtools/package.json +++ b/packages/io-devtools/package.json @@ -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", diff --git a/packages/protocol-devtools-evm/package.json b/packages/protocol-devtools-evm/package.json index d0215bf2c..1220e8d1c 100644 --- a/packages/protocol-devtools-evm/package.json +++ b/packages/protocol-devtools-evm/package.json @@ -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" diff --git a/packages/protocol-devtools/package.json b/packages/protocol-devtools/package.json index 2b81b0ab9..d47fa1109 100644 --- a/packages/protocol-devtools/package.json +++ b/packages/protocol-devtools/package.json @@ -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", diff --git a/packages/ua-devtools-evm/package.json b/packages/ua-devtools-evm/package.json index 713448047..191d71746 100644 --- a/packages/ua-devtools-evm/package.json +++ b/packages/ua-devtools-evm/package.json @@ -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" diff --git a/tests/devtools-evm-hardhat-test/package.json b/tests/devtools-evm-hardhat-test/package.json index cea02184d..3a06613b8 100644 --- a/tests/devtools-evm-hardhat-test/package.json +++ b/tests/devtools-evm-hardhat-test/package.json @@ -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", diff --git a/tests/devtools-evm-test/package.json b/tests/devtools-evm-test/package.json index 09fda390e..581b3841e 100644 --- a/tests/devtools-evm-test/package.json +++ b/tests/devtools-evm-test/package.json @@ -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", diff --git a/tests/ua-devtools-evm-hardhat-test/package.json b/tests/ua-devtools-evm-hardhat-test/package.json index 5166d5011..dec05b7d0 100644 --- a/tests/ua-devtools-evm-hardhat-test/package.json +++ b/tests/ua-devtools-evm-hardhat-test/package.json @@ -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",