Skip to content

Commit

Permalink
chore: ensure playwright cache consistency across environments
Browse files Browse the repository at this point in the history
  • Loading branch information
lgersman committed Nov 18, 2024
1 parent 7cbd9ab commit 028aa81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@
}
},

"appPort": [8888, 8889, 9003, 6006],

"postStartCommand": "rm -rf ./playwright/.cache"
"appPort": [8888, 8889, 9003, 6006]
}
12 changes: 12 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@
# bootstrap the environment
source "$(realpath $0 | xargs dirname)/includes/bootstrap.sh"

# ensure the playwright cache is generated in the same environment (devcontainer or local) as the tests are executed
# (this is necessary because the cache is not portable between environments)
(
PLAYWRIGHT_DIR=$(realpath ./playwright)
if [[ -f "$PLAYWRIGHT_DIR/.cache/metainfo.json" ]] && ! grep "$PLAYWRIGHT_DIR" ./playwright/.cache/metainfo.json > /dev/null; then
# ./playwright/.cache/metainfo.json contains not the absolute path to the cache directory of the current environment
rm -rf "$PLAYWRIGHT_DIR/.cache"
fi
)

# execute playwright tests
pnpm exec playwright test -c ./playwright-ct.config.js $@

exit 0

WPENV_INSTALLPATH="$(realpath --relative-to $(pwd) $(pnpm exec wp-env install-path))"

#region start wp-env if it is not running
Expand Down

0 comments on commit 028aa81

Please sign in to comment.