Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/integration-tests/suites/public-api/init/console/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable no-console */
import { ConsoleMessage, expect } from '@playwright/test';

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

// Regression test against https://github.com/getsentry/sentry-javascript/issues/4558
sentryTest('should not change console output', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

// https://playwright.dev/docs/api/class-page#page-event-console
page.on('console', (msg: ConsoleMessage) => {
expect(msg.text()).toEqual(`hello world ${msg.type()}`);
});

await page.goto(url);

await page.evaluate(() => console.log('hello', 'world', 'log'));

await page.evaluate(() => console.warn('hello', 'world', 'warning'));

await page.evaluate(() => console.debug('hello', 'world', 'debug'));
});
7 changes: 7 additions & 0 deletions packages/integration-tests/suites/public-api/init/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
});
11 changes: 11 additions & 0 deletions packages/integration-tests/suites/public-api/init/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
</head>
<body>
<script src="{{htmlWebpackPlugin.options.subject}}"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion packages/integrations/src/captureconsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class CaptureConsole implements Integration {

// this fails for some browsers. :(
if (originalConsoleMethod) {
originalConsoleMethod.call(global.console, args);
originalConsoleMethod.apply(global.console, args);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function instrumentConsole(): void {

// this fails for some browsers. :(
if (originalConsoleMethod) {
originalConsoleMethod.call(global.console, args);
originalConsoleMethod.apply(global.console, args);
}
};
});
Expand Down