From eff961eb079b98b7b00613bb973354ac373706be Mon Sep 17 00:00:00 2001
From: Emilien Escalle <neilime@users.noreply.github.com>
Date: Wed, 24 Feb 2021 11:38:58 +0100
Subject: [PATCH] Add how-to handle Jest cache

---
 examples.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/examples.md b/examples.md
index 1f6ecef..68f6be7 100644
--- a/examples.md
+++ b/examples.md
@@ -19,6 +19,7 @@
 - [Node - Lerna](#node---lerna)
 - [Node - Yarn](#node---yarn)
 - [Node - Yarn 2](#node---yarn-2)
+- [Node - Jest](#node---jest)
 - [OCaml/Reason - esy](#ocamlreason---esy)
 - [PHP - Composer](#php---composer)
 - [Python - pip](#python---pip)
@@ -295,6 +296,24 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
       ${{ runner.os }}-yarn-
 ```
 
+## Node - Jest
+The Jest cache directory will depend on your config. See https://jestjs.io/docs/cli#--cache for more info.
+
+```yaml
+- name: Get Jest cache directory path
+  id: jest-cache-dir-path
+  run: |
+    JEST_CACHE_DIR=$(yarn jest --showConfig | grep -o '"cacheDirectory": "[^"]*' | grep -o '[^"]*$')
+    echo "::set-output name=dir::$JEST_CACHE_DIR"
+
+- uses: actions/cache@v2
+  with:
+    path: ${{ steps.jest-cache-dir-path.outputs.dir }}
+    key: ${{ runner.os }}-jest-${{ github.sha }}
+    restore-keys: |
+      ${{ runner.os }}-jest-
+```
+
 ## OCaml/Reason - esy
 
 Esy allows you to export built dependencies and import pre-built dependencies.