|
@@ -35,9 +35,7 @@ describe('crashReporter module', () => {
|
|
|
|
|
|
beforeEach(() => {
|
|
|
stopServer = null
|
|
|
- w = new BrowserWindow(Object.assign({
|
|
|
- show: false
|
|
|
- }, browserWindowOpts))
|
|
|
+ w = new BrowserWindow(Object.assign({ show: false }, browserWindowOpts))
|
|
|
})
|
|
|
|
|
|
afterEach(() => closeWindow(w).then(() => { w = null }))
|
|
@@ -73,7 +71,6 @@ describe('crashReporter module', () => {
|
|
|
done: done
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
it('should send minidump when node processes crash', function (done) {
|
|
|
if (process.env.APPVEYOR === 'True') return done()
|
|
|
if (process.env.TRAVIS === 'true') return done()
|
|
@@ -106,7 +103,6 @@ describe('crashReporter module', () => {
|
|
|
done: done
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
it('should not send minidump if uploadToServer is false', function (done) {
|
|
|
this.timeout(120000)
|
|
|
|
|
@@ -168,7 +164,6 @@ describe('crashReporter module', () => {
|
|
|
done: testDone.bind(null, true)
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
it('should send minidump with updated extra parameters', function (done) {
|
|
|
if (process.env.APPVEYOR === 'True') return done()
|
|
|
if (process.env.TRAVIS === 'true') return done()
|
|
@@ -180,12 +175,12 @@ describe('crashReporter module', () => {
|
|
|
const crashUrl = url.format({
|
|
|
protocol: 'file',
|
|
|
pathname: path.join(fixtures, 'api', 'crash-restart.html'),
|
|
|
- search: '?port=' + port
|
|
|
+ search: `?port=${port}`
|
|
|
})
|
|
|
w.loadURL(crashUrl)
|
|
|
},
|
|
|
processType: 'renderer',
|
|
|
- done: done
|
|
|
+ done: done()
|
|
|
})
|
|
|
})
|
|
|
})
|
|
@@ -199,7 +194,22 @@ describe('crashReporter module', () => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- describe('.start(options)', () => {
|
|
|
+ describe('getProductName', () => {
|
|
|
+ it('returns the product name if one is specified', () => {
|
|
|
+ const name = crashReporter.getProductName()
|
|
|
+ const expectedName = (process.platform === 'darwin') ? 'Electron Test' : 'Zombies'
|
|
|
+ assert.equal(name, expectedName)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('getTempDirectory', () => {
|
|
|
+ it('returns temp directory for app if one is specified', () => {
|
|
|
+ const tempDir = crashReporter.getTempDirectory()
|
|
|
+ assert.equal(tempDir, app.getPath('temp'))
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('start(options)', () => {
|
|
|
it('requires that the companyName and submitURL options be specified', () => {
|
|
|
assert.throws(() => {
|
|
|
crashReporter.start({companyName: 'Missing submitURL'})
|
|
@@ -208,7 +218,6 @@ describe('crashReporter module', () => {
|
|
|
crashReporter.start({submitURL: 'Missing companyName'})
|
|
|
}, /companyName is a required option to crashReporter\.start/)
|
|
|
})
|
|
|
-
|
|
|
it('can be called multiple times', () => {
|
|
|
assert.doesNotThrow(() => {
|
|
|
crashReporter.start({
|
|
@@ -224,12 +233,41 @@ describe('crashReporter module', () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('.get/setUploadToServer', () => {
|
|
|
+ describe('getCrashesDirectory', () => {
|
|
|
+ it('correctly returns the directory', () => {
|
|
|
+ const crashesDir = crashReporter.getCrashesDirectory()
|
|
|
+ let dir
|
|
|
+ if (process.platform === 'win32') {
|
|
|
+ dir = `${app.getPath('temp')}/Zombies Crashes`
|
|
|
+ } else {
|
|
|
+ dir = `${app.getPath('temp')}/Electron Test Crashes`
|
|
|
+ }
|
|
|
+ assert.equal(crashesDir, dir)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('getUploadedReports', () => {
|
|
|
+ it('returns an array of reports', () => {
|
|
|
+ const reports = crashReporter.getUploadedReports()
|
|
|
+ assert(typeof reports === 'object')
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('getLastCrashReport', () => {
|
|
|
+ it('correctly returns the most recent report', () => {
|
|
|
+ if (process.env.TRAVIS === 'False') {
|
|
|
+ const reports = crashReporter.getUploadedReports()
|
|
|
+ const lastReport = reports[0]
|
|
|
+ assert(lastReport != null)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('getUploadToServer()', () => {
|
|
|
it('throws an error when called from the renderer process', () => {
|
|
|
assert.throws(() => require('electron').crashReporter.getUploadToServer())
|
|
|
})
|
|
|
-
|
|
|
- it('can be read/set from the main process', () => {
|
|
|
+ it('returns true when uploadToServer is set to true', () => {
|
|
|
if (process.platform === 'darwin') {
|
|
|
crashReporter.start({
|
|
|
companyName: 'Umbrella Corporation',
|
|
@@ -237,13 +275,87 @@ describe('crashReporter module', () => {
|
|
|
uploadToServer: true
|
|
|
})
|
|
|
assert.equal(crashReporter.getUploadToServer(), true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ it('returns false when uploadToServer is set to false', () => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes',
|
|
|
+ uploadToServer: true
|
|
|
+ })
|
|
|
crashReporter.setUploadToServer(false)
|
|
|
assert.equal(crashReporter.getUploadToServer(), false)
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('setUploadToServer(uploadToServer)', () => {
|
|
|
+ it('throws an error when called from the renderer process', () => {
|
|
|
+ assert.throws(() => require('electron').crashReporter.setUploadToServer('arg'))
|
|
|
+ })
|
|
|
+ it('sets uploadToServer false when called with false', () => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes',
|
|
|
+ uploadToServer: true
|
|
|
+ })
|
|
|
+ crashReporter.setUploadToServer(false)
|
|
|
+ assert.equal(crashReporter.getUploadToServer(), false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ it('sets uploadToServer true when called with true', () => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes',
|
|
|
+ uploadToServer: false
|
|
|
+ })
|
|
|
+ crashReporter.setUploadToServer(true)
|
|
|
assert.equal(crashReporter.getUploadToServer(), true)
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+ describe('Parameters', () => {
|
|
|
+ it('returns all of the current parameters', () => {
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes'
|
|
|
+ })
|
|
|
+
|
|
|
+ const parameters = crashReporter.getParameters()
|
|
|
+ assert(typeof parameters === 'object')
|
|
|
+ })
|
|
|
+ it('adds a parameter to current parameters', () => {
|
|
|
+ // only run on MacOS
|
|
|
+ if (process.platform !== 'darwin') return
|
|
|
+
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes'
|
|
|
+ })
|
|
|
+
|
|
|
+ crashReporter.addExtraParameter('hello', 'world')
|
|
|
+ assert('hello' in crashReporter.getParameters())
|
|
|
+ })
|
|
|
+ it('removes a parameter from current parameters', () => {
|
|
|
+ // only run on MacOS
|
|
|
+ if (process.platform !== 'darwin') return
|
|
|
+
|
|
|
+ crashReporter.start({
|
|
|
+ companyName: 'Umbrella Corporation',
|
|
|
+ submitURL: 'http://127.0.0.1/crashes'
|
|
|
+ })
|
|
|
+
|
|
|
+ crashReporter.addExtraParameter('hello', 'world')
|
|
|
+ assert('hello' in crashReporter.getParameters())
|
|
|
+
|
|
|
+ crashReporter.removeExtraParameter('hello')
|
|
|
+ assert(!('hello' in crashReporter.getParameters()))
|
|
|
+ })
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
const waitForCrashReport = () => {
|