Cypress caching

Hello there :wave:,

While researching this topic, we’ve noticed that Cypress installation uses $HOME/.cache/Cypress and $HOME/<<project_name>>/node_modules folders. Caching these two folders should be enough. However, after cached folders are restored, it is important to run Cypress install command as well. Files will not be downloaded again since they are all present. The install time should be significantly shorter (~5 sec vs ~25 sec in our tests).

You may create something similar to the following:


# restore node_modules folder from the cache
cache restore node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),node-modules-$SEMAPHORE_GIT_BRANCH,node-modules-master

# restore Cypress files from the cache
cd $HOME
cache restore cypress_cache

# run Cypress install & verify it works
yarn add cypress --dev
$(npm bin)/cypress --version

# store node_modules folder in the cache
cache store node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock)

# store Cypress in the cache
cd $HOME
cache store cypress_cache .cache/Cypress
1 Like