Skip to content

Commit

Permalink
Merge 94a226d into f1e85dc
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 authored Jul 17, 2020
2 parents f1e85dc + 94a226d commit 1f7909a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ class Server extends KarmaEventEmitter {
})
}

fileList.refresh().then(afterPreprocess, afterPreprocess)
fileList.refresh().then(afterPreprocess, (err) => {
this.log.error('Error during file loading or preprocessing\n' + err.stack || err)
afterPreprocess()
})

this.on('browsers_change', () => socketServer.sockets.emit('info', capturedBrowsers.serialize()))

Expand Down
7 changes: 6 additions & 1 deletion test/unit/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const BundleUtils = require('../../lib/utils/bundle-utils')
const NetUtils = require('../../lib/utils/net-utils')
const BrowserCollection = require('../../lib/browser_collection')
const Browser = require('../../lib/browser')
const logger = require('../../lib/logger')

describe('server', () => {
let mockConfig
Expand All @@ -16,6 +17,7 @@ describe('server', () => {
let mockBoundServer
let mockExecutor
let doneSpy
let logErrorSpy
let server = mockConfig = browserCollection = webServerOnError = null
let fileListOnResolve = fileListOnReject = mockLauncher = null
let mockFileList = mockWebServer = mockSocketServer = mockExecutor = doneSpy = null
Expand All @@ -27,6 +29,7 @@ describe('server', () => {
this.timeout(4000)
browserCollection = new BrowserCollection()
doneSpy = sinon.spy()
logErrorSpy = sinon.spy(logger.create('karma-server'), 'error')

fileListOnResolve = fileListOnReject = null

Expand Down Expand Up @@ -213,10 +216,12 @@ describe('server', () => {
expect(mockWebServer.listen).not.to.have.been.called
expect(server._injector.invoke).not.to.have.been.calledWith(mockLauncher.launch, mockLauncher)

fileListOnReject()
const fileListRefreshError = new Error('file-list refresh error')
fileListOnReject(fileListRefreshError)
expect(mockWebServer.listen).to.have.been.calledWith(mockBoundServer, sinon.match.func)
expect(webServerOnError).not.to.be.null
expect(server._injector.invoke).to.have.been.calledWith(mockLauncher.launch, mockLauncher)
expect(logErrorSpy).to.have.been.calledWith('Error during file loading or preprocessing\n' + fileListRefreshError.stack)
})

it('should launch browsers after the web server has started', async () => {
Expand Down

0 comments on commit 1f7909a

Please sign in to comment.