test: add spec for contentTracing.stopRecording (#18391)

This commit is contained in:
Shelley Vohr 2019-05-23 10:15:08 -07:00 committed by GitHub
parent 72b1c01836
commit b48dd6a11c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,10 +15,6 @@ const timeout = async (milliseconds) => {
})
}
const getPathInATempFolder = (filename) => {
return path.join(app.getPath('temp'), filename)
}
describe('contentTracing', () => {
beforeEach(function () {
// FIXME: The tests are skipped on arm/arm64.
@ -38,7 +34,7 @@ describe('contentTracing', () => {
return resultFilePath
}
const outputFilePath = getPathInATempFolder('trace.json')
const outputFilePath = path.join(app.getPath('temp'), 'trace.json')
beforeEach(() => {
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath)
@ -115,6 +111,18 @@ describe('contentTracing', () => {
describe('stopRecording', function () {
this.timeout(5e3)
it('does not crash on empty string', async () => {
const options = {
categoryFilter: '*',
traceOptions: 'record-until-full,enable-sampling'
}
await contentTracing.startRecording(options)
const path = await contentTracing.stopRecording('')
expect(path).to.be.a('string').that.is.not.empty()
expect(fs.statSync(path).isFile()).to.be.true()
})
it('calls its callback with a result file path', async () => {
const resultFilePath = await record(/* options */ {}, outputFilePath)
expect(resultFilePath).to.be.a('string').and.be.equal(outputFilePath)