Skip to content

Commit a7a9d8a

Browse files
committed
test
1 parent 4b22708 commit a7a9d8a

File tree

17 files changed

+268
-2
lines changed

17 files changed

+268
-2
lines changed

packages/e2e-tests/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ async function run(): Promise<void> {
2222
};
2323

2424
try {
25-
registrySetup();
25+
// registrySetup();
2626

27-
const recipePaths = glob.sync(`${__dirname}/test-applications/*/test-recipe.json`, { absolute: true });
27+
const recipePaths = glob.sync(`${__dirname}/test-applications/sveltekit/test-recipe.json`, { absolute: true });
2828

2929
await runAllTestApps(recipePaths, envVarsToInject);
3030
} catch (error) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
vite.config.js.timestamp-*
10+
vite.config.ts.timestamp-*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://localhost:4873
2+
@sentry-internal:registry=http://localhost:4873
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# create-svelte
2+
3+
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
4+
5+
## Creating a project
6+
7+
If you're seeing this, you've probably already done this step. Congrats!
8+
9+
```bash
10+
# create a new project in the current directory
11+
npm create svelte@latest
12+
13+
# create a new project in my-app
14+
npm create svelte@latest my-app
15+
```
16+
17+
## Developing
18+
19+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20+
21+
```bash
22+
npm run dev
23+
24+
# or start the server and open the app in a new browser tab
25+
npm run dev -- --open
26+
```
27+
28+
## Building
29+
30+
To create a production version of your app:
31+
32+
```bash
33+
npm run build
34+
```
35+
36+
You can preview the production build with `npm run preview`.
37+
38+
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "sveltekit",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite dev",
7+
"build": "vite build",
8+
"preview": "vite preview",
9+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11+
"test:prod": "TEST_ENV=production playwright test",
12+
"test:dev": "TEST_ENV=development playwright test"
13+
},
14+
"dependencies": {
15+
"@sentry/sveltekit": "*"
16+
},
17+
"devDependencies": {
18+
"@sveltejs/adapter-auto": "^2.0.0",
19+
"@sveltejs/kit": "^1.5.0",
20+
"svelte": "^3.54.0",
21+
"svelte-check": "^3.0.1",
22+
"tslib": "^2.4.1",
23+
"typescript": "^5.0.0",
24+
"vite": "^4.2.0",
25+
"ts-node": "10.9.1",
26+
"@playwright/test": "^1.27.1"
27+
},
28+
"type": "module"
29+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import { devices } from '@playwright/test';
3+
4+
const testEnv = process.env.TEST_ENV;
5+
6+
if (!testEnv) {
7+
throw new Error('No test env defined');
8+
}
9+
10+
const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO);
11+
12+
/**
13+
* See https://playwright.dev/docs/test-configuration.
14+
*/
15+
const config: PlaywrightTestConfig = {
16+
testDir: './tests',
17+
/* Maximum time one test can run for. */
18+
timeout: 60 * 1000,
19+
expect: {
20+
/**
21+
* Maximum time expect() should wait for the condition to be met.
22+
* For example in `await expect(locator).toHaveText();`
23+
*/
24+
timeout: 10000,
25+
},
26+
/* Run tests in files in parallel */
27+
fullyParallel: true,
28+
/* Fail the build on CI if you accidentally left test.only in the source code. */
29+
forbidOnly: !!process.env.CI,
30+
/* `next dev` is incredibly buggy with the app dir */
31+
retries: testEnv === 'development' ? 3 : 0,
32+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
33+
reporter: 'list',
34+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
35+
use: {
36+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
37+
actionTimeout: 0,
38+
/* Base URL to use in actions like `await page.goto('/')`. */
39+
baseURL: `http://localhost:${port}`,
40+
41+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
42+
trace: 'on-first-retry',
43+
},
44+
45+
/* Configure projects for major browsers */
46+
projects: [
47+
{
48+
name: 'chromium',
49+
use: {
50+
...devices['Desktop Chrome'],
51+
},
52+
},
53+
],
54+
55+
/* Run your local dev server before starting the tests */
56+
webServer: [
57+
{
58+
command: testEnv === 'development' ? `yarn preview --port ${port}` : `yarn preview --port ${port}`,
59+
port,
60+
},
61+
{
62+
command: 'yarn ts-node --esm start-event-proxy.ts',
63+
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP),
64+
},
65+
],
66+
};
67+
68+
export default config;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
6+
<meta name="viewport" content="width=device-width" />
7+
%sveltekit.head%
8+
</head>
9+
<body data-sveltekit-preload-data="hover">
10+
<div style="display: contents">%sveltekit.body%</div>
11+
</body>
12+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as Sentry from '@sentry/sveltekit';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
tunnel: `http://localhost:${
6+
Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP)
7+
}/`, // proxy server
8+
tracesSampleRate: 1.0,
9+
});
10+
11+
const myErrorHandler = ({ error, event }: any) => {
12+
console.error('An error occurred on the client side:', error, event);
13+
};
14+
15+
export const handleError = Sentry.handleErrorWithSentry(myErrorHandler);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as Sentry from '@sentry/sveltekit';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
tunnel: `http://localhost:${
6+
Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP)
7+
}/`, // proxy server
8+
tracesSampleRate: 1.0,
9+
});
10+
11+
const myErrorHandler = ({ error, event }: any) => {
12+
console.error('An error occurred on the client side:', error, event);
13+
};
14+
15+
export const handleError = Sentry.handleErrorWithSentry(myErrorHandler);
16+
17+
export const handle = Sentry.sentryHandle;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Welcome to SvelteKit</h1>
2+
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '../../test-utils/event-proxy-server';
2+
3+
startEventProxyServer({
4+
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP),
5+
proxyServerName: 'sveltekit',
6+
});
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import adapter from '@sveltejs/adapter-auto';
2+
import { vitePreprocess } from '@sveltejs/kit/vite';
3+
4+
/** @type {import('@sveltejs/kit').Config} */
5+
const config = {
6+
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
7+
// for more information about preprocessors
8+
preprocess: vitePreprocess(),
9+
10+
kit: {
11+
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12+
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
13+
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
14+
adapter: adapter()
15+
}
16+
};
17+
18+
export default config;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "../../test-recipe-schema.json",
3+
"testApplicationName": "Sveltekit",
4+
"buildCommand": "yarn install && yarn build",
5+
"tests": [
6+
{
7+
"testName": "Prod Mode",
8+
"testCommand": "yarn test:prod"
9+
},
10+
{
11+
"testName": "Dev Mode",
12+
"testCommand": "yarn test:dev"
13+
}
14+
]
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./.svelte-kit/tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": true,
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"resolveJsonModule": true,
9+
"skipLibCheck": true,
10+
"sourceMap": true,
11+
"strict": true
12+
// "allowImportingTsExtensions": true
13+
}
14+
// "include": ["./start-event-proxy.ts", "../../test-utils/**/*"]
15+
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
16+
//
17+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
18+
// from the referenced tsconfig.json - TypeScript does not merge them in
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { sveltekit } from '@sveltejs/kit/vite';
2+
import { sentrySvelteKit } from '@sentry/sveltekit';
3+
import { defineConfig } from 'vite';
4+
5+
export default defineConfig({
6+
plugins: [
7+
sentrySvelteKit({
8+
autoUploadSourceMaps: false,
9+
}),
10+
sveltekit(),
11+
],
12+
});

packages/e2e-tests/test-utils/event-proxy-server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,6 @@ async function retrieveCallbackServerPort(serverName: string): Promise<string> {
247247
const tmpFilePath = path.join(os.tmpdir(), `${TEMP_FILE_PREFIX}${serverName}`);
248248
return await readFile(tmpFilePath, 'utf8');
249249
}
250+
251+
// /Users/abhijeetprasad/workspace/sentry-javascript/packages/e2e-tests/test-utils/event-proxy-server.ts
252+
// /Users/abhijeetprasad/workspace/sentry-javascript/packages/e2e-tests/test-utils/event-proxy-server

0 commit comments

Comments
 (0)