Skip to content

Commit ebf10b2

Browse files
VItest + Playwright migration (#2007)
Co-authored-by: Atila Fassina <atila@fassina.eu>
1 parent fc91e60 commit ebf10b2

27 files changed

Lines changed: 770 additions & 3395 deletions

.github/workflows/tests.yml

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ name: 🧪 Tests
22

33
on:
44
workflow_dispatch:
5+
# Add remaining triggers
56
pull_request:
6-
branches: [main, 1.x]
7+
branches: [main]
78
push:
8-
branches: [main, 1.x]
9+
branches: [main]
910

1011
jobs:
1112
tests:
12-
name: "🧪 Tests"
13+
name: "🧪 Run All Tests"
1314
runs-on: ubuntu-24.04
1415
steps:
1516
- uses: actions/checkout@v3
@@ -25,37 +26,19 @@ jobs:
2526
- name: Install project dependencies
2627
run: pnpm i
2728

28-
- name: Install Cypress binary
29-
run: pnpm exec cypress install
29+
- name: Install Playwright Browsers
30+
run: pnpm --filter tests exec playwright install chromium
3031

3132
- name: Build SolidStart
3233
run: pnpm --filter @solidjs/start build
3334

3435
- name: Build Test Project
3536
run: pnpm --filter tests build
3637

37-
- name: Run unit tests
38-
run: pnpm --filter tests unit:ci
38+
- name: Run all apps/tests (Unit, Node, Browser UI, and E2E)
39+
run: pnpm --filter tests run test:all
3940

40-
- name: Run start unit tests
41-
run: pnpm --filter @solidjs/start test:ci
42-
43-
- name: E2E Chromium
44-
uses: cypress-io/github-action@v6
45-
with:
46-
project: ./apps/tests
47-
install: false
48-
start: pnpm --filter tests start --host 127.0.0.1 --port 3000
49-
wait-on: "http://127.0.0.1:3000"
50-
wait-on-timeout: 120
51-
browser: chromium
52-
53-
- name: E2E Firefox
54-
uses: cypress-io/github-action@v6
55-
with:
56-
project: ./apps/tests
57-
install: false
58-
start: pnpm --filter tests start --host 127.0.0.1 --port 3000
59-
wait-on: "http://127.0.0.1:3000"
60-
wait-on-timeout: 120
61-
browser: firefox
41+
# The @solidjs/start package currently has no tests, so we are skipping this step.
42+
# Uncomment if tests are added to the @solidjs/start package.
43+
# - name: Run @solidjs/start unit tests
44+
# run: pnpm --filter @solidjs/start test:ci

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ vite.config.ts.timestamp*
5050
.nitro
5151
.output
5252

53-
# ignore cypress screenshots
54-
**/cypress/screenshots
55-
5653
.data
5754
tsconfig.tsbuildinfo
55+
56+
apps/tests/**/test-results

CONTRIBUTING.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,23 @@ We recommend using the `create-solid` package with the **basic** setting.
5454

5555
You can also fork this repository and go to `apps/tests`.
5656
There we have an app with all default configurations and many routes.
57-
Create a new route, a Cypress assertion to it and open a PR with the failing test-case.
57+
Create a new route, a Vitest or Playwright assertion (as appropriate) to it and open a PR with the failing test-case.
5858

5959
Once the PR is there, **create an issue** and link the PR (mention the PR as you'd mention a person in the issue description and vice versa).
6060

61+
##### On testing
62+
63+
- If what you'd like to change needs e2e testing (i.e. you need a working build to test your feature), use playwright (see the `/app/tests/e2e` directory for examples).
64+
- If what you'd like to change is specific to a component, function (i.e. you need a unit test), use Vitest. You can find examples in the `/app/tests/` directory, look for the .tests.ts/.test.tsx files.
65+
- Note: Vitest is also set-up to test individual components - have a look at `/app/tests/routes/(basic).browser.test.tsx` for an example.
66+
67+
#### Testing conventions:
68+
69+
- For e2e test, simply place them in the `apps/tests/e2e` directory. The project is configured to run anything found in that directory via playwright as an e2e test.
70+
- For unit tests, co-locate them in the same place as the component or function they test:
71+
- E.g. If you're testing `/app/tests/MyComponent.tsx`, create a file named `/app/tests/MyComponent.test.browser.tsx` in the same directory. Note the `.browser` part - that's important to tell Vitest that this test should run in a browser environment.
72+
- For server-side unit tests, use the same placement conventions as described for components, but create a file named `/app/tests/myfeature.test.server.ts` in the same directory. Using `.server` in the filename tells Vitest that this test should run in a node environment.
73+
6174
> [!IMPORTANT]
6275
> Mark the **allow edit by the maintainers** so we can more easily investigate the failing test and propose a fix. Otherwise we may need to close your PR and cherry-pick your commit.
6376

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SolidStart is a pnpm-based monorepo with nested workspaces. Key directories incl
3131

3232
- **`packages/start`**: The core `@solidjs/start` package.
3333
- **`apps/landing-page`**: The official landing page.
34-
- **`apps/tests`**: Unit and end-to-end (E2E) tests using Vitest and Cypress.
34+
- **`apps/tests`**: Unit and end-to-end (E2E) tests using Vitest and Playwright.
3535
- **`apps/fixtures`**: Fixture projects for testing.
3636

3737
Use pnpm filters (e.g. `pnpm --filter @solidjs/start ...`) to target specific packages.
@@ -76,10 +76,10 @@ Then reinstall dependencies and rebuild.
7676

7777
End-to-end tests are located in `apps/tests` projects. For manual testing and development use the `apps/fixtures` apps, and finally, integration and unit tests live inside their respective packages.
7878

79-
1. Install the Cypress binary (required only once)
79+
1. Install the Chromium for Playwright binary (required only once)
8080

8181
```bash
82-
pnpm --filter tests exec cypress install
82+
pnpm --filter tests exec playwright install chromium
8383
```
8484

8585
2. For unit tests that check build artifacts, build the test app first
@@ -88,7 +88,7 @@ End-to-end tests are located in `apps/tests` projects. For manual testing and de
8888
pnpm --filter tests run build
8989
```
9090

91-
3. Run unit tests
91+
3. Run unit tests (puts vitest in watch mode)
9292

9393
```bash
9494
pnpm --filter tests run unit
@@ -100,11 +100,10 @@ End-to-end tests are located in `apps/tests` projects. For manual testing and de
100100
4. Run E2E tests
101101

102102
```bash
103-
pnpm --filter tests run tests:run
103+
pnpm --filter tests run e2e
104104
```
105105

106-
- Interactive mode: `pnpm --filter tests run tests:open`
107-
- With dev server: `pnpm --filter tests run tests`
106+
- UI mode: `pnpm --filter tests run e2e:ui`
108107

109108
5. Clean test artifacts
110109
```bash

apps/tests/cypress.config.ts

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

apps/tests/cypress/e2e/hydration.cy.ts

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

apps/tests/cypress/e2e/route-groups.cy.ts

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

apps/tests/cypress/e2e/server-function.cy.ts

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

apps/tests/cypress/support/e2e.ts

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

apps/tests/package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"dev": "vite dev",
77
"build": "vite build",
88
"start": "vite serve",
9-
"unit:ci": "vitest run",
109
"unit": "vitest",
1110
"unit:ui": "vitest --ui",
12-
"e2e:open": "cypress open",
13-
"e2e:run": "cypress run",
14-
"e2e": "pnpm run dev & cypress run"
11+
"unit:ci": "vitest run",
12+
"e2e": "playwright test",
13+
"e2e:ui": "playwright test --ui",
14+
"test:all": "npm run unit:ci && npm run e2e"
1515
},
1616
"dependencies": {
1717
"@solidjs/meta": "^0.29.4",
@@ -20,20 +20,19 @@
2020
"@solidjs/testing-library": "^0.8.10",
2121
"@testing-library/jest-dom": "^6.6.2",
2222
"@testing-library/user-event": "^14.5.2",
23-
"@vitest/ui": "3.0.5",
23+
"@vitest/ui": "^4.0.10",
2424
"jsdom": "^25.0.1",
2525
"lodash": "^4.17.21",
2626
"solid-js": "^1.9.9",
2727
"vite": "^7.1.10",
2828
"vite-plugin-solid": "^2.11.9",
29-
"vitest": "3.0.5"
29+
"vitest": "^4.0.10"
3030
},
3131
"devDependencies": {
32-
"@cypress/code-coverage": "^3.14.0",
32+
"@playwright/test": "^1.56.1",
3333
"@types/lodash": "^4.17.14",
34-
"@vitest/browser": "^3.0.4",
35-
"cypress": "^14.3.0",
36-
"cypress-plugin-tab": "^1.0.5",
37-
"cypress-vite": "^1.6.0"
34+
"@vitest/browser": "^4.0.10",
35+
"@vitest/browser-playwright": "^4.0.10",
36+
"playwright": "^1.56.1"
3837
}
3938
}

0 commit comments

Comments
 (0)