Skip to content

Commit 750de7d

Browse files
committed
[DX] Rework testing process, add test script to packages package.json
1 parent 9fd585d commit 750de7d

File tree

21 files changed

+52
-39
lines changed

21 files changed

+52
-39
lines changed

Diff for: bin/run-vitest-all.sh renamed to bin/test_package.sh

+32-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
#!/bin/bash
22

3+
# This script is used to test an UX package.
4+
# It also handle the case where a package has multiple versions of a peerDependency defined.
5+
6+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
7+
PROJECT_DIR=$(dirname "$SCRIPT_DIR")
8+
39
# Flag to track if any test fails
410
all_tests_passed=true
511

12+
# Check if we have at least one argument
13+
if [ $# -eq 0 ]
14+
then
15+
echo "No arguments supplied, please provide the package's path."
16+
fi
17+
618
# Check if jq is installed
719
if ! command -v jq &> /dev/null; then
820
echo "jq is required but not installed. Aborting."
@@ -11,16 +23,31 @@ fi
1123

1224
runTestSuite() {
1325
echo -e "Running tests for $workspace...\n"
14-
yarn workspace $workspace run -T vitest --run || { all_tests_passed=false; }
26+
yarn run -T vitest --run || { all_tests_passed=false; }
1527
}
1628

1729
processWorkspace() {
18-
local workspace="$1"
19-
local location="$2"
30+
local location="$1"
2031

21-
echo -e "Processing workspace $workspace at location $location...\n"
32+
if [ ! -d "$location" ]; then
33+
echo "No directory found at $location"
34+
return
35+
fi
2236

2337
package_json_path="$location/package.json"
38+
if [ ! -f "$package_json_path" ]; then
39+
echo "No package.json found at $package_json_path"
40+
return
41+
fi
42+
43+
workspace=$(jq -r '.name' "$package_json_path")
44+
if [ -z "$workspace" ]; then
45+
echo "No name found in package.json at $package_json_path"
46+
return
47+
fi
48+
49+
echo -e "Processing workspace $workspace at location $location...\n"
50+
2451
echo "Checking '$package_json_path' for peerDependencies with multiple versions defined"
2552
deps_with_multiple_versions=$(jq -r '.peerDependencies | to_entries[] | select(.value | contains("||")) | .key' "$package_json_path")
2653

@@ -48,21 +75,7 @@ processWorkspace() {
4875
fi
4976
}
5077

51-
# Iterate over each workspace using process substitution
52-
while IFS= read -r workspace_info; do
53-
# Split the workspace_info into workspace and location
54-
workspace=$(echo "$workspace_info" | jq -r '.name')
55-
location=$(echo "$workspace_info" | jq -r '.location')
56-
57-
# Skip the root workspace
58-
if [ $workspace == "null" ]; then
59-
continue
60-
fi
61-
62-
# Call the function to process the workspace
63-
processWorkspace "$workspace" "$location"
64-
65-
done < <(yarn workspaces list --json)
78+
processWorkspace "$(realpath "$PWD/$1")"
6679

6780
# Check the flag at the end and exit with code 1 if any test failed
6881
if [ "$all_tests_passed" = false ]; then

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"scripts": {
99
"build": "yarn workspaces foreach -Apt run build",
10-
"test": "bin/run-vitest-all.sh",
10+
"test": "yarn workspaces foreach -Apt run test",
1111
"lint": "biome lint --write",
1212
"format": "biome format --write",
1313
"check-lint": "biome lint",

Diff for: src/Autocomplete/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/Chartjs/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "node ../../../bin/build_package.js .",
1111
"watch": "node ../../../bin/build_package.js . --watch",
12-
"test": "echo 'The test script is not yet configured.' && exit 1",
12+
"test": "../../../bin/test_package.sh .",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check-lint": "biome lint",

Diff for: src/Cropperjs/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "node ../../../bin/build_package.js .",
1313
"watch": "node ../../../bin/build_package.js . --watch",
14-
"test": "echo 'The test script is not yet configured.' && exit 1",
14+
"test": "../../../bin/test_package.sh .",
1515
"lint": "biome lint --write",
1616
"format": "biome format --write",
1717
"check-lint": "biome lint",

Diff for: src/Dropzone/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "node ../../../bin/build_package.js .",
1313
"watch": "node ../../../bin/build_package.js . --watch",
14-
"test": "echo 'The test script is not yet configured.' && exit 1",
14+
"test": "../../../bin/test_package.sh .",
1515
"lint": "biome lint --write",
1616
"format": "biome format --write",
1717
"check-lint": "biome lint",

Diff for: src/LazyImage/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/LiveComponent/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "node ../../../bin/build_package.js .",
1313
"watch": "node ../../../bin/build_package.js . --watch",
14-
"test": "echo 'The test script is not yet configured.' && exit 1",
14+
"test": "../../../bin/test_package.sh .",
1515
"lint": "biome lint --write",
1616
"format": "biome format --write",
1717
"check-lint": "biome lint",

Diff for: src/Map/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "node ../../../bin/build_package.js .",
1111
"watch": "node ../../../bin/build_package.js . --watch",
12-
"test": "echo 'The test script is not yet configured.' && exit 1",
12+
"test": "../../../bin/test_package.sh .",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check-lint": "biome lint",

Diff for: src/Map/src/Bridge/Google/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "node ../../../../../../bin/build_package.js .",
1111
"watch": "node ../../../../../../bin/build_package.js . --watch",
12-
"test": "echo 'The test script is not yet configured.' && exit 1",
12+
"test": "../../../../../../bin/test_package.sh .",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check-lint": "biome lint",

Diff for: src/Map/src/Bridge/Leaflet/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "node ../../../../../../bin/build_package.js .",
1111
"watch": "node ../../../../../../bin/build_package.js . --watch",
12-
"test": "echo 'The test script is not yet configured.' && exit 1",
12+
"test": "../../../../../../bin/test_package.sh .",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check-lint": "biome lint",

Diff for: src/Notify/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/React/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/StimulusBundle/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "node ../../../bin/build_package.js .",
99
"watch": "node ../../../bin/build_package.js . --watch",
10-
"test": "echo 'The test script is not yet configured.' && exit 1",
10+
"test": "../../../bin/test_package.sh .",
1111
"lint": "biome lint --write",
1212
"format": "biome format --write",
1313
"check-lint": "biome lint",

Diff for: src/Svelte/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "node ../../../bin/build_package.js .",
99
"watch": "node ../../../bin/build_package.js . --watch",
10-
"test": "echo 'The test script is not yet configured.' && exit 1",
10+
"test": "../../../bin/test_package.sh .",
1111
"lint": "biome lint --write",
1212
"format": "biome format --write",
1313
"check-lint": "biome lint",

Diff for: src/Swup/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/TogglePassword/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "node ../../../bin/build_package.js .",
1313
"watch": "node ../../../bin/build_package.js . --watch",
14-
"test": "echo 'The test script is not yet configured.' && exit 1",
14+
"test": "../../../bin/test_package.sh .",
1515
"lint": "biome lint --write",
1616
"format": "biome format --write",
1717
"check-lint": "biome lint",

Diff for: src/Translator/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/Turbo/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "node ../../../bin/build_package.js .",
1111
"watch": "node ../../../bin/build_package.js . --watch",
12-
"test": "echo 'The test script is not yet configured.' && exit 1",
12+
"test": "../../../bin/test_package.sh .",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check-lint": "biome lint",

Diff for: src/Typed/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

Diff for: src/Vue/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "node ../../../bin/build_package.js .",
1010
"watch": "node ../../../bin/build_package.js . --watch",
11-
"test": "echo 'The test script is not yet configured.' && exit 1",
11+
"test": "../../../bin/test_package.sh .",
1212
"lint": "biome lint --write",
1313
"format": "biome format --write",
1414
"check-lint": "biome lint",

0 commit comments

Comments
 (0)