@element-hq/element-web-playwright-common 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@element-hq/element-web-playwright-common",
3
3
  "type": "module",
4
- "version": "1.4.1",
4
+ "version": "1.4.3",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,6 +30,7 @@
30
30
  "dependencies": {
31
31
  "@axe-core/playwright": "^4.10.1",
32
32
  "@testcontainers/postgresql": "^11.0.0",
33
+ "glob": "^11.0.3",
33
34
  "lodash-es": "^4.17.21",
34
35
  "mailpit-api": "^1.2.0",
35
36
  "strip-ansi": "^7.1.0",
@@ -5,21 +5,24 @@ SCRIPT_PATH=$(readlink -f "$0")
5
5
  SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
6
6
 
7
7
  IMAGE_NAME="element-web-playwright-common"
8
- echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
9
-
10
- # Build image
11
- PW_VERSION=$(
12
- yarn list \
13
- --pattern @playwright/test \
14
- --depth=0 \
15
- --json \
16
- --non-interactive \
17
- --no-progress | \
18
- jq -r '.data.trees[].name | split("@")[2]' \
19
- )
20
- echo "with Playwright version $PW_VERSION"
21
-
22
- docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=$PW_VERSION" "$SCRIPT_DIR"
8
+
9
+ build_image() {
10
+ echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
11
+
12
+ # Build image
13
+ PW_VERSION=$(
14
+ yarn list \
15
+ --pattern @playwright/test \
16
+ --depth=0 \
17
+ --json \
18
+ --non-interactive \
19
+ --no-progress | \
20
+ jq -r '.data.trees[].name | split("@")[2]' \
21
+ )
22
+ echo "with Playwright version $PW_VERSION"
23
+
24
+ docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=$PW_VERSION" "$SCRIPT_DIR"
25
+ }
23
26
 
24
27
  RUN_ARGS=(
25
28
  --rm
@@ -36,6 +39,35 @@ RUN_ARGS=(
36
39
  -it
37
40
  )
38
41
 
42
+ DEFAULT_ARGS=(--grep @screenshot)
43
+
44
+ # Some arguments to customise behaviour so the same script / image can be
45
+ # re-used for other screenshot generation.
46
+ while [[ $# -gt 0 ]]; do
47
+ case "$1" in
48
+ # Mounts a separate node_modules directory from a docker volume in the container.
49
+ # Must be used if executing something that requires native node modules
50
+ # It's a volume rather than a directory because otherwise things tend to start picking up
51
+ # files from it in the native environment and break.
52
+ --with-node-modules)
53
+ RUN_ARGS+=(--mount "type=volume,src=ew-docker-node-modules,dst=/work/node_modules,volume-nocopy")
54
+ shift
55
+ ;;
56
+ # Sets a different entrypoint (in which case the default arguments to the script will be ignored)
57
+ --entrypoint)
58
+ shift
59
+ RUN_ARGS+=(--entrypoint "$1")
60
+ DEFAULT_ARGS=()
61
+ shift
62
+ ;;
63
+ *)
64
+ break
65
+ ;;
66
+ esac
67
+ done
68
+
69
+ build_image
70
+
39
71
  # Ensure we pass all symlinked node_modules to the container
40
72
  pushd node_modules || exit > /dev/null
41
73
  SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
@@ -48,6 +80,4 @@ for LINK in $SYMLINKS; do
48
80
  fi
49
81
  done
50
82
 
51
- DEFAULT_ARGS=(--grep @screenshot)
52
-
53
- docker run "${RUN_ARGS[@]}" "$IMAGE_NAME" "${DEFAULT_ARGS[@]}" "$@"
83
+ docker run "${RUN_ARGS[@]}" "$IMAGE_NAME" "${DEFAULT_ARGS[@]}" "$@"