Skip to content

Commit 789231c

Browse files
authored
test(browser): Remove webpack build tests (#12967)
Removes `packages/browser/test/package/npm-build.js`. `packages/browser/test/package/npm-build.js` contained three tests: 1. Test against `tslib_1__default` appearing in the bundle. I added a browser integration test to replicate this 2. Test that adding a bundled package would work, our integration + e2e tests pretty much cover this 3. Test that you can add bundle packages multiple times - our integration + e2e tests also cover this I also migrated `packages/utils/test/types/index.js` to use jest instead of a plain script.
1 parent 6027036 commit 789231c

File tree

9 files changed

+89
-1227
lines changed

9 files changed

+89
-1227
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -779,33 +779,6 @@ jobs:
779779
name: playwright-traces
780780
path: dev-packages/browser-integration-tests/test-results
781781

782-
job_browser_build_tests:
783-
name: Browser Build Tests
784-
needs: [job_get_metadata, job_build]
785-
runs-on: ubuntu-20.04
786-
timeout-minutes: 5
787-
steps:
788-
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
789-
uses: actions/checkout@v4
790-
with:
791-
ref: ${{ env.HEAD_COMMIT }}
792-
- name: Set up Node
793-
uses: actions/setup-node@v4
794-
with:
795-
node-version-file: 'package.json'
796-
- name: Restore caches
797-
uses: ./.github/actions/restore-cache
798-
env:
799-
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
800-
- name: Run browser build tests
801-
run: |
802-
cd packages/browser
803-
yarn test:package
804-
- name: Run utils build tests
805-
run: |
806-
cd packages/utils
807-
yarn test:package
808-
809782
job_check_for_faulty_dts:
810783
name: Check for faulty .d.ts files
811784
needs: [job_get_metadata, job_build]
@@ -1317,7 +1290,6 @@ jobs:
13171290
[
13181291
job_build,
13191292
job_compile_bindings_profiling_node,
1320-
job_browser_build_tests,
13211293
job_browser_unit_tests,
13221294
job_bun_unit_tests,
13231295
job_deno_unit_tests,

packages/browser/test/package/test-code.js renamed to dev-packages/browser-integration-tests/suites/public-api/init/built-pkg/subject.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
/* eslint-disable no-console */
2-
const Sentry = require('../../build/npm/cjs/index.js');
3-
4-
// Init
5-
Sentry.init({
6-
dsn: 'https://completelyrandom@dsn.asdf/42',
7-
beforeSend(_event) {
8-
console.log('Got an event');
9-
return null;
10-
},
11-
beforeBreadcrumb(crumb) {
12-
console.log(`Got a breadcrumb: ${crumb.category}`);
13-
return crumb;
14-
},
15-
});
16-
17-
// Configure
181
const scope = Sentry.getCurrentScope();
192
scope.setExtra('foo', 'bar');
203
scope.setFingerprint('foo');
@@ -75,6 +58,5 @@ Sentry.withScope(scope => {
7558

7659
var xhr = new XMLHttpRequest();
7760
xhr.onload = () => console.log('loaded'); // This throws error
78-
// xhr.addEventListener("load", () => console.log('loaded')); This does not throw error
7961
xhr.open('GET', 'https://httpbin.org/get');
8062
xhr.send();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
4+
import { expect } from '@playwright/test';
5+
6+
import { sentryTest } from '../../../../utils/fixtures';
7+
8+
// Regression test against https://github.com/getsentry/sentry-javascript/pull/1896
9+
sentryTest('should not contain tslib_1__default', async ({ getLocalTestPath }) => {
10+
await getLocalTestPath({ testDir: __dirname });
11+
12+
const initBundle = fs.readFileSync(path.join(__dirname, 'dist', 'init.bundle.js'), 'utf-8');
13+
expect(initBundle.length).toBeGreaterThan(0);
14+
expect(initBundle).not.toContain('tslib_1__default');
15+
16+
const subjectBundle = fs.readFileSync(path.join(__dirname, 'dist', 'subject.bundle.js'), 'utf-8');
17+
expect(subjectBundle.length).toBeGreaterThan(0);
18+
expect(subjectBundle).not.toContain('tslib_1__default');
19+
});

packages/browser/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
},
5050
"devDependencies": {
5151
"@sentry-internal/integration-shims": "8.18.0",
52-
"fake-indexeddb": "^4.0.1",
53-
"webpack": "^4.47.0"
52+
"fake-indexeddb": "^4.0.1"
5453
},
5554
"scripts": {
5655
"build": "run-p build:transpile build:bundle build:types",
@@ -73,7 +72,6 @@
7372
"size:check": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES2017: \",$1,\"kB\";}'",
7473
"test": "yarn test:unit",
7574
"test:unit": "jest",
76-
"test:package": "node test/package/npm-build.js && rm test/package/tmp.js",
7775
"test:unit:watch": "jest --watch",
7876
"yalc:publish": "yalc publish --push --sig"
7977
},

packages/browser/test/package/npm-build.js

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

packages/utils/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"lint": "eslint . --format stylish",
6464
"test": "jest",
6565
"test:watch": "jest --watch",
66-
"test:package": "node test/types/index.js",
6766
"version": "node ../../scripts/versionbump.js src/version.ts",
6867
"yalc:publish": "yalc publish --push --sig"
6968
},

packages/utils/test/types/index.js

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
4+
const testStrings = ['/// <reference types="node" />'];
5+
6+
const paths = [path.join('./build/cjs'), path.join('./build/esm')];
7+
8+
test('typedef', () => {
9+
paths.forEach(dir => {
10+
if (!fs.existsSync(dir)) {
11+
throw new Error(`${dir} doesn't exist please build first`);
12+
}
13+
const files = fs.readdirSync(dir);
14+
files.forEach(file => {
15+
if (file.includes('.d.ts')) {
16+
testStrings.forEach(testString => {
17+
const filePath = path.join(dir, file);
18+
if (fs.readFileSync(filePath, 'utf8').includes(testString)) {
19+
throw new Error(`${filePath} contains types`);
20+
}
21+
});
22+
}
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)