Skip to content

Commit efde516

Browse files
committed
Configure Vitest for unit and browser tests
1 parent 5eb1153 commit efde516

File tree

86 files changed

+1703
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1703
-364
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,16 @@ jobs:
143143
fi
144144
js:
145145
runs-on: ubuntu-latest
146-
strategy:
147-
fail-fast: false
148-
matrix:
149-
node-version: [ '18.x', '20.x', '22.x', '24.x' ]
150146
steps:
151147
- uses: actions/checkout@v4
152148
- run: npm i -g corepack && corepack enable
153149
- uses: actions/setup-node@v4
154150
with:
155-
node-version: ${{ matrix.node-version }}
151+
node-version-file: '.nvmrc'
156152
cache: 'pnpm'
157153
cache-dependency-path: |
158154
pnpm-lock.yaml
159155
package.json
160156
src/**/package.json
161157
- run: pnpm install --frozen-lockfile
162-
- run: pnpm exec playwright install chromium
163158
- run: pnpm run test

bin/test_package.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,46 @@ if ! command -v jq &> /dev/null; then
2222
fi
2323

2424
runTestSuite() {
25-
echo -e "Running tests for $workspace...\n"
25+
echo -e "🧪 Running tests for $workspace...\n"
2626
pnpm exec vitest --run || { all_tests_passed=false; }
2727
}
2828

2929
processWorkspace() {
3030
local location="$1"
3131

3232
if [ ! -d "$location" ]; then
33-
echo "No directory found at $location"
33+
echo "No directory found at $location"
3434
return
3535
fi
3636

3737
package_json_path="$location/package.json"
3838
if [ ! -f "$package_json_path" ]; then
39-
echo "No package.json found at $package_json_path"
39+
echo "No package.json found at $package_json_path"
4040
return
4141
fi
4242

4343
workspace=$(jq -r '.name' "$package_json_path")
4444
if [ -z "$workspace" ]; then
45-
echo "No name found in package.json at $package_json_path"
45+
echo "No name found in package.json at $package_json_path"
4646
return
4747
fi
4848

49-
echo -e "Processing workspace $workspace at location $location...\n"
49+
echo -e "Processing workspace $workspace at location $location...\n"
5050

51-
echo "Checking '$package_json_path' for peerDependencies and importmap dependencies to have the same version"
51+
echo "⚙️ Checking '$package_json_path' for peerDependencies and importmap dependencies to have the same version"
5252
deps=$(jq -r '.peerDependencies | keys[]' "$package_json_path")
5353
for library in $deps; do
5454
version=$(jq -r ".peerDependencies.\"$library\"" "$package_json_path")
55-
importmap_version=$(jq -r ".symfony.importmap.\"$library\"" "$package_json_path")
55+
importmap_version=$(jq -r ".symfony.importmap.\"$library\" | if type == \"string\" then . else .version end" "$package_json_path")
5656

5757
if [ "$version" != "$importmap_version" ]; then
58-
echo " -> Version mismatch for $library: $version (peerDependencies) vs $importmap_version (importmap)"
59-
echo " -> You need to match the version of the \"peerDependency\" with the version in the \"importmap\""
60-
exit
58+
echo " Version mismatch for $library: $version (peerDependencies) vs $importmap_version (importmap)"
59+
echo " You need to match the version of the \"peerDependency\" with the version in the \"importmap\""
60+
exit 1
6161
fi
6262
done
6363

64-
echo "Checking '$package_json_path' for peerDependencies with multiple versions defined"
64+
echo "⚙️ Checking '$package_json_path' for peerDependencies with multiple versions defined"
6565
deps_with_multiple_versions=$(jq -r '.peerDependencies | to_entries[] | select(.value | contains("||")) | .key' "$package_json_path")
6666

6767
if [ -n "$deps_with_multiple_versions" ]; then
@@ -84,7 +84,7 @@ processWorkspace() {
8484
done
8585

8686
echo " -> Reverting version changes from $package_json_path"
87-
git checkout -- "$package_json_path"
87+
git checkout -- "$package_json_path" "$PROJECT_DIR/pnpm-lock.yaml"
8888
else
8989
echo -e " -> No peerDependencies found with multiple versions defined\n"
9090
runTestSuite

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"scripts": {
1010
"build": "pnpm run --filter @symfony/ux-map build && pnpm run -r --aggregate-output build",
11-
"test": "pnpm run -r --aggregate-output test",
11+
"test": "pnpm run -r --workspace-concurrency=1 test",
1212
"check": "biome check",
1313
"ci": "biome ci"
1414
},
@@ -19,10 +19,10 @@
1919
"@types/node": "^22.6.0",
2020
"lightningcss": "^1.28.2",
2121
"pkg-types": "^2.2.0",
22-
"playwright": "^1.47.0",
2322
"tinyglobby": "^0.2.14",
2423
"tsup": "^8.5.0",
25-
"vitest": "^3.2.4"
24+
"vitest": "^3.2.4",
25+
"webdriverio": "^9.19.1"
2626
},
2727
"version": "2.27.0"
2828
}

0 commit comments

Comments
 (0)