mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add process.takeHeapSnapshot() / webContents.takeHeapSnapshot() (#14456)
This commit is contained in:
committed by
Shelley Vohr
parent
1855144d26
commit
e22142ef9c
@@ -1,3 +1,7 @@
|
||||
const { remote } = require('electron')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const { expect } = require('chai')
|
||||
|
||||
describe('process module', () => {
|
||||
@@ -67,4 +71,32 @@ describe('process module', () => {
|
||||
expect(heapStats.doesZapGarbage).to.be.a('boolean')
|
||||
})
|
||||
})
|
||||
|
||||
describe('process.takeHeapSnapshot()', () => {
|
||||
it('returns true on success', () => {
|
||||
const filePath = path.join(remote.app.getPath('temp'), 'test.heapsnapshot')
|
||||
|
||||
const cleanup = () => {
|
||||
try {
|
||||
fs.unlinkSync(filePath)
|
||||
} catch (e) {
|
||||
// ignore error
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const success = process.takeHeapSnapshot(filePath)
|
||||
expect(success).to.be.true()
|
||||
const stats = fs.statSync(filePath)
|
||||
expect(stats.size).not.to.be.equal(0)
|
||||
} finally {
|
||||
cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
it('returns false on failure', () => {
|
||||
const success = process.takeHeapSnapshot('')
|
||||
expect(success).to.be.false()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user