Skip to content

Commit 5490eed

Browse files
authored
Merge pull request #2678 from bugsnag/revert-1882-remove-coverage-from-pr-bot
Reinstate code coverage check
2 parents f4c387b + 1534c8f commit 5490eed

5 files changed

Lines changed: 43 additions & 22 deletions

File tree

.github/workflows/pr-diff.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ jobs:
2121
- name: Record before stats
2222
env:
2323
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
24+
ELECTRON_DISABLE_SANDBOX: 1
2425
run: |
2526
mkdir .diff
2627
npm ci
2728
npm run build
29+
npm run test:coverage
2830
cat packages/browser/dist/bugsnag.min.js | wc -c > .diff/size-before-minified
2931
cat packages/browser/dist/bugsnag.min.js | gzip | wc -c > .diff/size-before-gzipped
32+
cp coverage/coverage-summary.json .diff/coverage-before.json
3033
3134
- name: Checkout PR branch
3235
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -36,11 +39,14 @@ jobs:
3639
- name: Record after stats
3740
env:
3841
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
42+
ELECTRON_DISABLE_SANDBOX: 1
3943
run: |
4044
npm ci
4145
npm run build
46+
npm run test:coverage
4247
cat packages/browser/dist/bugsnag.min.js | wc -c > .diff/size-after-minified
4348
cat packages/browser/dist/bugsnag.min.js | gzip | wc -c > .diff/size-after-gzipped
49+
cp coverage/coverage-summary.json .diff/coverage-after.json
4450
4551
- name: Run danger
4652
uses: danger/danger-js@67ed2c1f42fd2fc198cc3c14b43c8f83351f4fe9 # 13.0.5

dangerfile.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/* global markdown */
22

33
const { readFileSync } = require('fs')
4+
const coverageDiff = require('coverage-diff')
45

56
const before = {
67
minified: parseInt(readFileSync(`${__dirname}/.diff/size-before-minified`, 'utf8').trim()),
7-
gzipped: parseInt(readFileSync(`${__dirname}/.diff/size-before-gzipped`, 'utf8').trim())
8+
gzipped: parseInt(readFileSync(`${__dirname}/.diff/size-before-gzipped`, 'utf8').trim()),
9+
coverage: JSON.parse(readFileSync(`${__dirname}/.diff/coverage-before.json`, 'utf8'))
810
}
911

1012
const after = {
1113
minified: parseInt(readFileSync(`${__dirname}/.diff/size-after-minified`, 'utf8').trim()),
12-
gzipped: parseInt(readFileSync(`${__dirname}/.diff/size-after-gzipped`, 'utf8').trim())
14+
gzipped: parseInt(readFileSync(`${__dirname}/.diff/size-after-gzipped`, 'utf8').trim()),
15+
coverage: JSON.parse(readFileSync(`${__dirname}/.diff/coverage-after.json`, 'utf8'))
1316
}
1417

1518
const formatKbs = (n) => `${(n / 1000).toFixed(2)} kB`
@@ -33,5 +36,5 @@ markdown(`
3336
3437
### code coverage diff
3538
36-
<_temporarily disabled_>
39+
${coverageDiff.diff(before.coverage, after.coverage).results}
3740
`)

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ module.exports = {
5353
'plugin-browser-session',
5454
'plugin-network-instrumentation'
5555
], {
56-
testEnvironment: '<rootDir>/jest/FixJSDOMEnvironment.js'
56+
testEnvironment: '<rootDir>/jest/FixJSDOMEnvironment.js',
57+
modulePathIgnorePatterns: ['.verdaccio', 'dist', 'examples', 'fixtures']
5758
}),
5859
project('react native', [
5960
'react-native',

packages/node/test/notifier.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ describe('node notifier', () => {
1212
Bugsnag._client = null
1313
})
1414

15+
afterEach(() => {
16+
// Clean up process listeners to prevent MaxListenersExceeded warning
17+
// The unhandledRejection and uncaughtException plugins register listeners
18+
// but don't have destroy methods called automatically
19+
process.removeAllListeners('unhandledRejection')
20+
process.removeAllListeners('uncaughtException')
21+
jest.clearAllMocks()
22+
})
23+
1524
describe('isStarted()', () => {
1625
it('returns false when the notifier has not been initialised', () => {
1726
expect(Bugsnag.isStarted()).toBe(false)
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1+
(function () {
12
// preloads run in devtools panes too, but we don't want to run there
2-
if (document.location.protocol === 'devtools:') return
3+
if (document.location.protocol === 'devtools:') return
34

4-
const { ipcRenderer, contextBridge } = require('electron')
5-
const BugsnagIpcRenderer = require('./bugsnag-ipc-renderer')
6-
const { CHANNEL_CONFIG } = require('./lib/constants')
5+
const { ipcRenderer, contextBridge } = require('electron')
6+
const BugsnagIpcRenderer = require('./bugsnag-ipc-renderer')
7+
const { CHANNEL_CONFIG } = require('./lib/constants')
78

8-
// one sync call is required on startup to get the main process config
9-
const config = ipcRenderer.sendSync(CHANNEL_CONFIG)
10-
if (!config) throw new Error('Bugsnag was not started in the main process before browser windows were created')
9+
// one sync call is required on startup to get the main process config
10+
const config = ipcRenderer.sendSync(CHANNEL_CONFIG)
11+
if (!config) throw new Error('Bugsnag was not started in the main process before browser windows were created')
1112

12-
// attach config to the exposed interface
13-
BugsnagIpcRenderer.config = JSON.parse(config)
13+
// attach config to the exposed interface
14+
BugsnagIpcRenderer.config = JSON.parse(config)
1415

15-
// attach process info to the exposed interface
16-
const { isMainFrame, sandboxed, type } = process
17-
BugsnagIpcRenderer.process = { isMainFrame, sandboxed, type }
16+
// attach process info to the exposed interface
17+
const { isMainFrame, sandboxed, type } = process
18+
BugsnagIpcRenderer.process = { isMainFrame, sandboxed, type }
1819

19-
// expose Bugsnag as a global object for the browser
20-
try {
20+
// expose Bugsnag as a global object for the browser
21+
try {
2122
// assume contextIsolation=true
22-
contextBridge.exposeInMainWorld('__bugsnag_ipc__', BugsnagIpcRenderer)
23-
} catch (e) {}
23+
contextBridge.exposeInMainWorld('__bugsnag_ipc__', BugsnagIpcRenderer)
24+
} catch (e) {}
2425

25-
// expose for other preload scripts to use, this also covers contextIsolation=false
26-
window.__bugsnag_ipc__ = BugsnagIpcRenderer
26+
// expose for other preload scripts to use, this also covers contextIsolation=false
27+
window.__bugsnag_ipc__ = BugsnagIpcRenderer
28+
})()

0 commit comments

Comments
 (0)