Skip to content

Commit 893370e

Browse files
authored
test: Shard E2E Tests (#1239)
1 parent 22dbfa8 commit 893370e

File tree

12 files changed

+111
-112
lines changed

12 files changed

+111
-112
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
run: yarn install
2323
- name: Build
2424
run: yarn build
25-
- name: Pack
26-
run: yarn pack
2725
- name: Archive Artifacts
2826
uses: actions/upload-artifact@v4
2927
with:
@@ -73,8 +71,9 @@ jobs:
7371
strategy:
7472
fail-fast: false
7573
matrix:
76-
os: [ubuntu-22.04, windows-latest, macos-latest]
74+
os: [ubuntu-latest, windows-2022, macos-latest]
7775
electron: ${{ fromJson(needs.build.outputs.matrix) }}
76+
shard: [1, 2, 3, 4]
7877
env:
7978
ELECTRON_VERSION: ${{ matrix.electron }}
8079
steps:
@@ -83,9 +82,13 @@ jobs:
8382
with:
8483
node-version-file: 'package.json'
8584
- run: yarn install
85+
- name: Download Artifacts
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: ${{ github.sha }}
8689
- name: Run E2E Tests
87-
timeout-minutes: 30
88-
run: yarn e2e
90+
timeout-minutes: 10
91+
run: yarn e2e --shard=${{ matrix.shard }}/4
8992

9093
required_jobs_passed:
9194
name: All required jobs passed or were skipped

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@
8585
"access": "public"
8686
},
8787
"scripts": {
88-
"prebuild": "yarn clean && node scripts/update-version.js",
88+
"set-version": "node scripts/update-version.js",
89+
"prebuild": "yarn clean && yarn set-version",
8990
"build": "rollup --config rollup.config.mjs",
90-
"postbuild": "node scripts/check-exports.mjs && node scripts/check-types.mjs",
91+
"postbuild": "node scripts/check-exports.mjs && node scripts/check-types.mjs && node scripts/check-loading.mjs && yarn pack",
9192
"clean": "rimraf --glob coverage common esm main preload renderer index.* sentry-electron*.tgz .eslintcache",
92-
"prelint": "node scripts/update-version.js",
93+
"prelint": "yarn set-version",
9394
"lint": "run-s lint:prettier lint:eslint",
9495
"lint:prettier": "prettier --check \"{src,test,examples}/**/*.{ts,js}\"",
9596
"lint:eslint": "eslint . --cache --format stylish",
@@ -98,9 +99,9 @@
9899
"fix:eslint": "eslint . --format stylish --fix",
99100
"update-electron-versions": "electron-latest-versions --start 23 --beta > ./test/e2e/versions.json",
100101
"update-sdk-versions": "node ./scripts/update-sdk-versions.mjs",
101-
"pretest": "yarn build",
102+
"pretest": "yarn set-version",
102103
"test": "vitest run --root=./test/unit",
103-
"pree2e": "rimraf --glob test/e2e/dist/**/node_modules/@sentry/** test/e2e/dist/**/yarn.lock test/e2e/dist/**/package-lock.json && node scripts/clean-cache.js && yarn build && npm pack",
104+
"pree2e": "yarn set-version && rimraf --glob test/e2e/dist/**/node_modules/@sentry/** test/e2e/dist/**/yarn.lock test/e2e/dist/**/package-lock.json && node scripts/clean-cache.js",
104105
"e2e": "xvfb-maybe vitest run --root=./test/e2e --silent=false --disable-console-intercept"
105106
},
106107
"dependencies": {

scripts/check-loading.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { spawnSync } from 'node:child_process';
2+
3+
const result = spawnSync('yarn', ['electron', 'scripts/getPathCheck', '--no-sandbox'], { stdio: 'inherit' });
4+
5+
// We don't get the correct status on Windows 🤷‍♂️
6+
if (process.platform === 'win32' && result.status !== 0) {
7+
process.exit(1);
8+
}

test/unit/getPath-test-app/main.js renamed to scripts/getPathCheck/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ app.getPath = () => {
88
app.exit(1);
99
};
1010

11-
require('../../../main');
11+
require('../../main');
1212

1313
app.exit(0);

scripts/getPathCheck/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "electron-test",
3+
"version": "1.0.0",
4+
"main": "main.js"
5+
}

test/e2e/prepare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function prepareTestFiles(
9696
// We replace the @sentry/electron dependency in package.json with the path to the tarball
9797
.replace(
9898
/"@sentry\/electron": ".*"/,
99-
`"@sentry/electron": "file:./../../../../sentry-electron-${SDK_VERSION}.tgz"`,
99+
`"@sentry/electron": "file:./../../../../sentry-electron-v${SDK_VERSION}.tgz"`,
100100
)
101101
// We replace the Sentry JavaScript dependency versions to match that of @sentry/core
102102
.replace(/"@sentry\/replay": ".*"/, `"@sentry/replay": "${JS_SDK_VERSION}"`)

test/e2e/test-apps/other/child-process/test.ts

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

4-
electronTestRunner(__dirname, async (ctx) => {
4+
electronTestRunner(__dirname, { skip: () => process.platform === 'linux' }, async (ctx) => {
55
await ctx
66
.expect({
77
envelope: eventEnvelope({

test/e2e/test-apps/sessions/native-crash-main/test.ts

Lines changed: 76 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,85 @@ import {
99
UUID_MATCHER,
1010
} from '../../..';
1111

12-
electronTestRunner(__dirname, { runTwice: true, timeout: 50_000 }, async (ctx) => {
13-
let firstSessionId: string | undefined;
12+
electronTestRunner(
13+
__dirname,
14+
{ runTwice: true, timeout: 50_000, skip: () => process.platform === 'linux' },
15+
async (ctx) => {
16+
let firstSessionId: string | undefined;
1417

15-
await ctx
16-
.includeSessionEnvelopes()
17-
.ignoreExpectationOrder()
18-
.expect({
19-
envelope: (envelope: Envelope) => {
20-
const session = getSessionFromEnvelope(envelope);
21-
firstSessionId = session?.sid;
22-
expect(firstSessionId).toBeDefined();
18+
await ctx
19+
.includeSessionEnvelopes()
20+
.ignoreExpectationOrder()
21+
.expect({
22+
envelope: (envelope: Envelope) => {
23+
const session = getSessionFromEnvelope(envelope);
24+
firstSessionId = session?.sid;
25+
expect(firstSessionId).toBeDefined();
2326

24-
expect(
25-
sessionEnvelope({
26-
sid: UUID_MATCHER,
27-
init: true,
28-
started: ISO_DATE_MATCHER,
29-
timestamp: ISO_DATE_MATCHER,
30-
status: 'ok',
31-
errors: 0,
32-
duration: expect.any(Number),
33-
}),
34-
).toEqual(envelope);
35-
},
36-
})
37-
.expect({
38-
envelope: sessionEnvelope({
39-
sid: UUID_MATCHER,
40-
init: true,
41-
started: ISO_DATE_MATCHER,
42-
timestamp: ISO_DATE_MATCHER,
43-
status: 'ok',
44-
errors: 0,
45-
duration: expect.any(Number),
46-
}),
47-
})
48-
.expect({
49-
envelope: (envelope: Envelope) => {
50-
const session = getSessionFromEnvelope(envelope);
51-
expect(session?.sid).toEqual(firstSessionId);
27+
expect(
28+
sessionEnvelope({
29+
sid: UUID_MATCHER,
30+
init: true,
31+
started: ISO_DATE_MATCHER,
32+
timestamp: ISO_DATE_MATCHER,
33+
status: 'ok',
34+
errors: 0,
35+
duration: expect.any(Number),
36+
}),
37+
).toEqual(envelope);
38+
},
39+
})
40+
.expect({
41+
envelope: sessionEnvelope({
42+
sid: UUID_MATCHER,
43+
init: true,
44+
started: ISO_DATE_MATCHER,
45+
timestamp: ISO_DATE_MATCHER,
46+
status: 'ok',
47+
errors: 0,
48+
duration: expect.any(Number),
49+
}),
50+
})
51+
.expect({
52+
envelope: (envelope: Envelope) => {
53+
const session = getSessionFromEnvelope(envelope);
54+
expect(session?.sid).toEqual(firstSessionId);
5255

53-
expect(
54-
sessionEnvelope({
55-
sid: UUID_MATCHER,
56-
init: false,
57-
started: ISO_DATE_MATCHER,
58-
timestamp: ISO_DATE_MATCHER,
59-
status: 'crashed',
60-
errors: 1,
61-
duration: expect.any(Number),
62-
}),
63-
).toEqual(envelope);
64-
},
65-
})
66-
.expect({
67-
envelope: eventEnvelope(
68-
{
69-
level: 'fatal',
70-
platform: 'native',
71-
tags: {
72-
'event.environment': 'native',
73-
'event.origin': 'electron',
74-
'event.process': 'browser',
75-
},
56+
expect(
57+
sessionEnvelope({
58+
sid: UUID_MATCHER,
59+
init: false,
60+
started: ISO_DATE_MATCHER,
61+
timestamp: ISO_DATE_MATCHER,
62+
status: 'crashed',
63+
errors: 1,
64+
duration: expect.any(Number),
65+
}),
66+
).toEqual(envelope);
7667
},
77-
[
68+
})
69+
.expect({
70+
envelope: eventEnvelope(
7871
{
79-
type: 'attachment',
80-
length: expect.any(Number),
81-
filename: expect.stringMatching(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.dmp$/),
82-
attachment_type: 'event.minidump',
72+
level: 'fatal',
73+
platform: 'native',
74+
tags: {
75+
'event.environment': 'native',
76+
'event.origin': 'electron',
77+
'event.process': 'browser',
78+
},
8379
},
84-
expect.any(Buffer),
85-
],
86-
),
87-
})
88-
.run();
89-
});
80+
[
81+
{
82+
type: 'attachment',
83+
length: expect.any(Number),
84+
filename: expect.stringMatching(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.dmp$/),
85+
attachment_type: 'event.minidump',
86+
},
87+
expect.any(Buffer),
88+
],
89+
),
90+
})
91+
.run();
92+
},
93+
);

test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ function createWindow() {
2424

2525
app.on('ready', () => {
2626
createWindow();
27-
});
2827

29-
setTimeout(() => {
30-
createWindow();
31-
}, 3000);
28+
setTimeout(() => {
29+
createWindow();
30+
}, 3000);
31+
});
3232

3333
setTimeout(() => {
3434
app.quit();

test/e2e/test-apps/sessions/native-crash-renderer-multiple/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
UUID_MATCHER,
99
} from '../../..';
1010

11-
electronTestRunner(__dirname, async (ctx) => {
11+
electronTestRunner(__dirname, { skip: () => process.platform === 'linux' }, async (ctx) => {
1212
let firstSessionId: string | undefined;
1313

1414
await ctx

0 commit comments

Comments
 (0)