Skip to content

Commit

Permalink
test(browser): Remove unused webpack build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jul 18, 2024
1 parent ac6e2f1 commit a323292
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 1,286 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -779,33 +779,6 @@ jobs:
name: playwright-traces
path: dev-packages/browser-integration-tests/test-results

job_browser_build_tests:
name: Browser Build Tests
needs: [job_get_metadata, job_build]
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Run browser build tests
run: |
cd packages/browser
yarn test:package
- name: Run utils build tests
run: |
cd packages/utils
yarn test:package
job_check_for_faulty_dts:
name: Check for faulty .d.ts files
needs: [job_get_metadata, job_build]
Expand Down Expand Up @@ -1317,7 +1290,6 @@ jobs:
[
job_build,
job_compile_bindings_profiling_node,
job_browser_build_tests,
job_browser_unit_tests,
job_bun_unit_tests,
job_deno_unit_tests,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/* eslint-disable no-console */
const Sentry = require('../../build/npm/cjs/index.js');

// Init
Sentry.init({
dsn: 'https://[email protected]/42',
beforeSend(_event) {
console.log('Got an event');
return null;
},
beforeBreadcrumb(crumb) {
console.log(`Got a breadcrumb: ${crumb.category}`);
return crumb;
},
});

// Configure
const scope = Sentry.getCurrentScope();
scope.setExtra('foo', 'bar');
scope.setFingerprint('foo');
Expand Down Expand Up @@ -75,6 +58,6 @@ Sentry.withScope(scope => {

var xhr = new XMLHttpRequest();
xhr.onload = () => console.log('loaded'); // This throws error
// xhr.addEventListener("load", () => console.log('loaded')); This does not throw error
xhr.addEventListener('load', () => console.log('loaded')); // This does not throw error
xhr.open('GET', 'https://httpbin.org/get');
xhr.send();
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as fs from 'node:fs';
import * as path from 'node:path';

import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';

// Regression test against https://github.com/getsentry/sentry-javascript/pull/1896
sentryTest('should not contain tslib_1__default', async ({ getLocalTestPath }) => {
await getLocalTestPath({ testDir: __dirname });

const initBundle = fs.readFileSync(path.join(__dirname, 'dist', 'init.bundle.js'), 'utf-8');
expect(initBundle.length).toBeGreaterThan(0);
expect(initBundle).not.toContain('tslib_1__default');

const subjectBundle = fs.readFileSync(path.join(__dirname, 'dist', 'subject.bundle.js'), 'utf-8');
expect(subjectBundle.length).toBeGreaterThan(0);
expect(subjectBundle).not.toContain('tslib_1__default');
});
4 changes: 1 addition & 3 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
},
"devDependencies": {
"@sentry-internal/integration-shims": "8.18.0",
"fake-indexeddb": "^4.0.1",
"webpack": "^4.47.0"
"fake-indexeddb": "^6.0.0"
},
"scripts": {
"build": "run-p build:transpile build:bundle build:types",
Expand All @@ -73,7 +72,6 @@
"size:check": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES2017: \",$1,\"kB\";}'",
"test": "yarn test:unit",
"test:unit": "jest",
"test:package": "node test/package/npm-build.js && rm test/package/tmp.js",
"test:unit:watch": "jest --watch",
"yalc:publish": "yalc publish --push --sig"
},
Expand Down
69 changes: 0 additions & 69 deletions packages/browser/test/package/npm-build.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"lint": "eslint . --format stylish",
"test": "jest",
"test:watch": "jest --watch",
"test:package": "node test/types/index.js",
"version": "node ../../scripts/versionbump.js src/version.ts",
"yalc:publish": "yalc publish --push --sig"
},
Expand Down
27 changes: 0 additions & 27 deletions packages/utils/test/types/index.js

This file was deleted.

25 changes: 25 additions & 0 deletions packages/utils/test/types/typedef.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as fs from 'node:fs';
import * as path from 'node:path';

const testStrings = ['/// <reference types="node" />'];

const paths = [path.join('./build/cjs'), path.join('./build/esm')];

test('typedef', () => {
paths.forEach(dir => {
if (!fs.existsSync(dir)) {
throw new Error(`${dir} doesn't exist please build first`);
}
const files = fs.readdirSync(dir);
files.forEach(file => {
if (file.includes('.d.ts')) {
testStrings.forEach(testString => {
const filePath = path.join(dir, file);
if (fs.readFileSync(filePath, 'utf8').includes(testString)) {
throw new Error(`${filePath} contains types`);
}
});
}
});
});
});
Loading

0 comments on commit a323292

Please sign in to comment.