Skip to content

Commit 6812eef

Browse files
Zen-cronicLms24
authored andcommitted
test(browser): Add initial setup for e2e test
1 parent 9ed2112 commit 6812eef

File tree

11 files changed

+167
-1
lines changed

11 files changed

+167
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
/test-results/
26+
/playwright-report/
27+
/playwright/.cache/
28+
29+
!*.d.ts
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as path from 'path';
2+
import * as url from 'url';
3+
import webpack from 'webpack';
4+
import HtmlWebpackPlugin from 'html-webpack-plugin';
5+
import TerserPlugin from 'terser-webpack-plugin';
6+
7+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
8+
9+
webpack(
10+
{
11+
entry: path.join(__dirname, 'src/index.js'),
12+
output: {
13+
path: path.join(__dirname, 'build'),
14+
filename: 'app.js',
15+
},
16+
optimization: {
17+
minimize: true,
18+
minimizer: [new TerserPlugin()],
19+
},
20+
plugins: [new webpack.EnvironmentPlugin(['E2E_TEST_DSN']), new HtmlWebpackPlugin()],
21+
mode: 'production',
22+
},
23+
(err, stats) => {
24+
if (err) {
25+
console.error(err.stack || err);
26+
if (err.details) {
27+
console.error(err.details);
28+
}
29+
return;
30+
}
31+
32+
const info = stats.toJson();
33+
34+
if (stats.hasErrors()) {
35+
console.error(info.errors);
36+
process.exit(1);
37+
}
38+
39+
if (stats.hasWarnings()) {
40+
console.warn(info.warnings);
41+
process.exit(1);
42+
}
43+
},
44+
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "default-browser-test-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@sentry/browser": "latest || *",
7+
"@types/node": "16.7.13",
8+
"typescript": "4.9.5"
9+
},
10+
"scripts": {
11+
"start": "serve -s build",
12+
"build": "node build.mjs",
13+
"test": "playwright test",
14+
"clean": "npx rimraf node_modules pnpm-lock.yaml",
15+
"test:build": "pnpm install && npx playwright install && pnpm build",
16+
"test:assert": "pnpm test"
17+
},
18+
"browserslist": {
19+
"production": [
20+
">0.2%",
21+
"not dead",
22+
"not op_mini all"
23+
],
24+
"development": [
25+
"last 1 chrome version",
26+
"last 1 firefox version",
27+
"last 1 safari version"
28+
]
29+
},
30+
"devDependencies": {
31+
"@playwright/test": "^1.44.1",
32+
"@sentry-internal/test-utils": "link:../../../test-utils",
33+
"webpack": "^5.91.0",
34+
"serve": "14.0.1",
35+
"terser-webpack-plugin": "^5.3.10",
36+
"html-webpack-plugin": "^5.6.0"
37+
},
38+
"volta": {
39+
"extends": "../../package.json"
40+
}
41+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: `pnpm start`,
5+
});
6+
7+
export default config;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Sentry from '@sentry/react';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
tunnel: 'http://localhost:3031',
6+
integrations: [Sentry.browserTracingIntegration()],
7+
});
8+
9+
setTimeout(() => {
10+
throw new Error('I am an error!');
11+
}, 2000);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'default-browser',
6+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('testing', () => {
4+
expect(true).toBe(true);
5+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2018",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"esModuleInterop": true,
8+
"allowSyntheticDefaultImports": true,
9+
"strict": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"noFallthroughCasesInSwitch": true,
12+
"module": "esnext",
13+
"moduleResolution": "node",
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "react"
18+
},
19+
"include": ["src", "tests"]
20+
}

dev-packages/e2e-tests/test-applications/react-19/tests/errors.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test('Catches errors caught by error boundary', async ({ page }) => {
77
});
88

99
const errorEventPromise = waitForError('react-19', event => {
10+
//ErrorEvent's type === undefined
1011
return !event.type && event.exception?.values?.[0]?.value === 'caught error';
1112
});
1213

dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from '@playwright/test';
22
import { ReplayRecordingData } from './fixtures/ReplayRecordingData';
33

4-
const EVENT_POLLING_TIMEOUT = 90_000;
4+
const EVENT_POLLING_TIMEOUT = 5_000;
55

66
const authToken = process.env.E2E_TEST_AUTH_TOKEN;
77
const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG;

0 commit comments

Comments
 (0)