Skip to content

Commit ead3b79

Browse files
committed
chore: update testing setup and remove obsolete workflow
- Updated the test command in package.json to include separate scripts for vitest and CLI integration tests. - Added a new script for running CLI integration tests. - Modified GitHub workflows to run tests in a more structured manner. - Removed the obsolete CLI integration test workflow file. - Updated .gitignore to exclude the new test project directory.
1 parent 70151db commit ead3b79

File tree

5 files changed

+64
-70
lines changed

5 files changed

+64
-70
lines changed

.github/workflows/cli-integration-test.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ jobs:
2424
run: pnpm run build
2525
- name: Install Playwright browsers
2626
run: pnpm exec playwright install --with-deps
27-
- name: Run tests
28-
run: pnpm test
29-
- name: Test wokwi-embed with Playwright
30-
run: pnpm test:embed:playwright
27+
- name: Run vitest tests
28+
run: pnpm run test:vitest
29+
- name: Run Playwright embed tests
30+
run: pnpm run test:embed:playwright
31+
- name: Run CLI integration tests
32+
run: pnpm run test:cli:integration
33+
env:
34+
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ diagram.json
66
screenshot.png
77
playwright-report/
88
test-results/
9+
test-project/

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
"clean": "pnpm -r run clean",
1010
"lint": "eslint .",
1111
"lint:fix": "eslint . --fix",
12-
"test": "pnpm run lint && vitest --run",
12+
"test": "pnpm run test:vitest && pnpm run test:embed:playwright && pnpm run test:cli:integration",
13+
"test:vitest": "pnpm run lint && vitest --run",
1314
"test:embed:playwright": "playwright test test/wokwi-embed",
1415
"test:embed:playwright:ui": "playwright test test/wokwi-embed --ui",
16+
"test:cli:integration": "bash scripts/test-cli-integration.sh",
1517
"cli": "tsx packages/wokwi-cli/src/main.ts",
1618
"prepare": "husky install"
1719
},

scripts/test-cli-integration.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TEST_PROJECT_DIR="test-project"
5+
TEST_REPO="https://github.com/wokwi/esp-idf-hello-world.git"
6+
7+
# Clone test project if it doesn't exist
8+
if [ ! -d "$TEST_PROJECT_DIR" ]; then
9+
echo "Cloning test project..."
10+
git clone "$TEST_REPO" "$TEST_PROJECT_DIR"
11+
else
12+
echo "Test project already exists, skipping clone..."
13+
fi
14+
15+
# Create test scenario file
16+
cat > "$TEST_PROJECT_DIR/test-scenario.yaml" << 'EOF'
17+
name: "Basic Hello World Test"
18+
version: 1
19+
description: "Test that the ESP32 hello world program outputs expected text"
20+
21+
steps:
22+
- name: "Wait for boot and hello message"
23+
wait-serial: "Hello world!"
24+
25+
- name: "Wait for chip information"
26+
wait-serial: "This is esp32 chip"
27+
28+
- name: "Wait for restart message"
29+
wait-serial: "Restarting in 10 seconds"
30+
EOF
31+
32+
echo "Test scenario file created."
33+
34+
# Check if WOKWI_CLI_TOKEN is set
35+
if [ -z "$WOKWI_CLI_TOKEN" ]; then
36+
echo "Warning: WOKWI_CLI_TOKEN environment variable is not set."
37+
echo "Integration tests require a Wokwi API token to run."
38+
echo "Set WOKWI_CLI_TOKEN environment variable to run these tests."
39+
exit 1
40+
fi
41+
42+
# Run CLI tests
43+
echo "Running CLI integration tests..."
44+
45+
echo "Test 1: Basic expect-text test"
46+
pnpm cli "$TEST_PROJECT_DIR" --timeout 5000 --expect-text "Hello"
47+
48+
echo "Test 2: Scenario file test"
49+
pnpm cli "$TEST_PROJECT_DIR" --scenario "test-scenario.yaml" --timeout 15000
50+
51+
echo "All CLI integration tests passed!"
52+

0 commit comments

Comments
 (0)