Skip to content

Commit 8b1f130

Browse files
authored
fix(solidstart): Use production server for e2e tests (#14033)
Adds a small post-build script to copy over deps that are not correctly resolved in our yarn workspace/pnpm e2e test applications (but do work correctly in standalone projects). This allows us to finally use the vinxi production server to run e2e tests and is similar to what the Nuxt SDK has to do. Also allows us to get rid of the double page loads for the first test to avoid hydration errors that were caused by the dev server previously.
1 parent 0815309 commit 8b1f130

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

dev-packages/e2e-tests/test-applications/solidstart/package.json

+5-13
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
"version": "0.0.0",
44
"scripts": {
55
"clean": "pnpx rimraf node_modules pnpm-lock.yaml .vinxi .output",
6-
"clean:build": "pnpx rimraf .vinxi .output",
76
"dev": "NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi dev",
8-
"build": "vinxi build",
9-
"//": [
10-
"We are using `vinxi dev` to start the server because `vinxi start` is experimental and ",
11-
"doesn't correctly resolve modules for @sentry/solidstart/solidrouter.",
12-
"This is currently not an issue outside of our repo. See: https://github.com/nksaraf/vinxi/issues/177",
13-
"We run the build command to ensure building succeeds. However, keeping",
14-
"build output around slows down the vite dev server when using `@sentry/vite-plugin` so we clear it out",
15-
"before actually running the tests.",
16-
"Cleaning the build output should be removed once we can use `vinxi start`."
17-
],
18-
"preview": "pnpm clean:build && HOST=localhost PORT=3030 NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi dev",
19-
"start": "HOST=localhost PORT=3030 NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi start",
7+
"build": "vinxi build && sh ./post_build.sh",
8+
"preview": "HOST=localhost PORT=3030 NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi start",
209
"test:prod": "TEST_ENV=production playwright test",
2110
"test:build": "pnpm install && npx playwright install && pnpm build",
2211
"test:assert": "pnpm test:prod"
@@ -41,5 +30,8 @@
4130
"vite": "^5.2.8",
4231
"vite-plugin-solid": "^2.10.2",
4332
"vitest": "^1.5.0"
33+
},
34+
"overrides": {
35+
"@vercel/nft": "0.27.4"
4436
}
4537
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# TODO: Investigate the need for this script periodically and remove once these modules are correctly resolved.
2+
3+
# This script copies `import-in-the-middle` and `@sentry/solidstart` from the E2E test project root `node_modules`
4+
# to the nitro server build output `node_modules` as these are not properly resolved in our yarn workspace/pnpm
5+
# e2e structure. Some files like `hook.mjs` and `@sentry/solidstart/solidrouter.server.js` are missing. This is
6+
# not reproducible in an external project (when pinning `@vercel/nft` to `v0.27.0` and higher).
7+
cp -r node_modules/.pnpm/import-in-the-middle@1.*/node_modules/import-in-the-middle .output/server/node_modules
8+
cp -rL node_modules/@sentry/solidstart .output/server/node_modules/@sentry

dev-packages/e2e-tests/test-applications/solidstart/tests/errorboundary.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ test('captures an exception', async ({ page }) => {
1010
);
1111
});
1212

13-
await page.goto('/error-boundary');
1413
await page.goto('/error-boundary');
1514
await page.locator('#caughtErrorBtn').click();
1615
const errorEvent = await errorEventPromise;
@@ -41,7 +40,6 @@ test('captures a second exception after resetting the boundary', async ({ page }
4140
);
4241
});
4342

44-
await page.goto('/error-boundary');
4543
await page.goto('/error-boundary');
4644
await page.locator('#caughtErrorBtn').click();
4745
const firstErrorEvent = await firstErrorEventPromise;

0 commit comments

Comments
 (0)