Skip to content

Commit 95dd3a2

Browse files
committed
ci: add e2e setup script
1 parent 2f0f54a commit 95dd3a2

File tree

3 files changed

+397
-26
lines changed

3 files changed

+397
-26
lines changed

.github/workflows/end-to-end-tests.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: End-to-end tests CI
2-
on: [pull_request]
2+
on: [pull_request, workflow_dispatch]
33
jobs:
44
test:
55
runs-on: ubuntu-latest
@@ -8,20 +8,13 @@ jobs:
88
- name: Test using Node.js
99
uses: actions/setup-node@v1
1010
with:
11-
node-version: "v20.11.0"
11+
node-version: "v22"
1212
- name: Install dependencies
1313
run: npm install
14-
- name: Install http-server
15-
run: npm install -g http-server pm2
16-
- name: Build e2e outputs
17-
run: npm run dev:e2e
18-
- name: Build production outputs
19-
run: npm run build
20-
21-
- name: Start up mock server
22-
run: |
23-
pm2 start 'http-server ./test-e2e/example -p 12345'
24-
pm2 start 'http-server ./test-e2e/example -p 12346'
14+
- name: Setup e2e environment
15+
run: bash script/setup-e2e.sh --all
16+
- name: Start test servers
17+
run: bash script/setup-e2e.sh --start-servers
2518

2619
- name: Run tests
2720
env:

CONTRIBUTING.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ npm run build:firefox
8585
npm run build:safari
8686
```
8787

88-
### 5. Testing Your Extension
88+
### 5. Debugging
8989

9090
#### Chrome/Edge
9191

@@ -126,23 +126,24 @@ This will generate coverage reports in the `coverage/` directory.
126126
127127
#### Setup E2E Testing
128128

129-
1. Build the test environment:
129+
Use the provided setup script to initialize the e2e testing environment:
130130

131131
```shell
132-
npm run dev:e2e
133-
npm run build
132+
# Initialize e2e environment (install dependencies and build outputs)
133+
bash script/setup-e2e.sh --init --build
134+
135+
# Start test servers
136+
bash script/setup-e2e.sh --start-servers
134137
```
135138

136-
2. Start test servers:
139+
The setup script will:
137140

138-
```shell
139-
npm install -g http-server pm2
140-
141-
pm2 start 'http-server ./test-e2e/example -p 12345'
142-
pm2 start 'http-server ./test-e2e/example -p 12346'
143-
```
141+
- Install/upgrade global dependencies (`http-server`, `pm2`)
142+
- Download browser for Puppeteer (if needed)
143+
- Build e2e test output (`dist_e2e/`)
144+
- Start test servers on ports 12345 and 12346
144145

145-
3. Run E2E tests:
146+
#### Run E2E Tests
146147

147148
```shell
148149
npm run test-e2e
@@ -157,6 +158,35 @@ export USE_HEADLESS_PUPPETEER=true
157158
npm run test-e2e
158159
```
159160

161+
#### Stop Test Servers
162+
163+
After testing, stop the servers:
164+
165+
```shell
166+
pm2 stop all && pm2 delete all
167+
```
168+
169+
#### Setup Script Options
170+
171+
The `setup-e2e.sh` script supports multiple options:
172+
173+
```shell
174+
# Show help
175+
bash script/setup-e2e.sh --help
176+
177+
# Initialize only (install dependencies)
178+
bash script/setup-e2e.sh --init
179+
180+
# Build e2e output only
181+
bash script/setup-e2e.sh --build
182+
183+
# Initialize and build
184+
bash script/setup-e2e.sh --init --build
185+
186+
# Run all steps (init + build + build production)
187+
bash script/setup-e2e.sh --all
188+
```
189+
160190
## Code Quality
161191

162192
### Code Formatting
@@ -234,7 +264,8 @@ time-tracker-4-browser/
234264
├── types/ # TypeScript declarations
235265
├── rspack/ # Build configuration
236266
├── script/ # Build and utility scripts
237-
│ └── android-firefox.sh # Android development helper
267+
│ ├── android-firefox.sh # Android development helper
268+
│ └── setup-e2e.sh # E2E test environment setup
238269
├── public/ # Static assets
239270
├── doc/ # Documentation
240271
├── dist_dev/ # Chrome/Edge dev build

0 commit comments

Comments
 (0)