Skip to content

Commit

Permalink
test: move debugger spec to main process (#20514)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon authored and zcbenz committed Oct 14, 2019
1 parent 5c2c301 commit 1f44f47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/api/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Returns:

* `event` Event
* `method` String - Method name.
* `params` unknown - Event parameters defined by the 'parameters'
* `params` any - Event parameters defined by the 'parameters'
attribute in the remote debugging protocol.

Emitted whenever the debugging target issues an instrumentation event.
Expand Down
33 changes: 15 additions & 18 deletions spec/api-debugger-spec.js → spec-main/api-debugger-spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const http = require('http')
const path = require('path')
const { emittedOnce } = require('./events-helpers')
const { closeWindow } = require('./window-helpers')
const { BrowserWindow } = require('electron').remote

const { expect } = chai
chai.use(dirtyChai)
import { expect } from 'chai'
import * as http from 'http'
import * as path from 'path'
import { AddressInfo } from 'net'
import { BrowserWindow } from 'electron'
import { closeAllWindows } from './window-helpers'
import { emittedOnce } from './events-helpers'

describe('debugger module', () => {
const fixtures = path.resolve(__dirname, 'fixtures')
let w = null
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
let w: BrowserWindow

beforeEach(() => {
w = new BrowserWindow({
Expand All @@ -21,7 +18,7 @@ describe('debugger module', () => {
})
})

afterEach(() => closeWindow(w).then(() => { w = null }))
afterEach(closeAllWindows)

describe('debugger.attach', () => {
it('succeeds when devtools is already open', done => {
Expand Down Expand Up @@ -87,19 +84,19 @@ describe('debugger module', () => {
})
w.webContents.debugger.on('detach', (e, reason) => {
expect(w.webContents.debugger.isAttached()).to.be.false()
expect(w.devToolsWebContents.isDestroyed()).to.be.false()
expect((w as any).devToolsWebContents.isDestroyed()).to.be.false()
done()
})
})
})

describe('debugger.sendCommand', () => {
let server
let server: http.Server

afterEach(() => {
if (server != null) {
server.close()
server = null
server = null as any
}
})

Expand Down Expand Up @@ -193,7 +190,7 @@ describe('debugger module', () => {

server.listen(0, '127.0.0.1', () => {
w.webContents.debugger.sendCommand('Network.enable')
w.loadURL(`http://127.0.0.1:${server.address().port}`)
w.loadURL(`http://127.0.0.1:${(server.address() as AddressInfo).port}`)
})
})

Expand All @@ -219,7 +216,7 @@ describe('debugger module', () => {

server.listen(0, '127.0.0.1', () => {
w.webContents.debugger.sendCommand('Network.enable')
w.loadURL(`http://127.0.0.1:${server.address().port}`)
w.loadURL(`http://127.0.0.1:${(server.address() as AddressInfo).port}`)
})
})
})
Expand Down

0 comments on commit 1f44f47

Please sign in to comment.