Skip to content

Commit e4b5cf4

Browse files
committed
fix(static-server): always set folder when unset
1 parent 0110f43 commit e4b5cf4

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/commands/static-server.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ export default class StaticServer {
1717
}
1818

1919
if (browser.config.staticServer === true) {
20-
const { folder } = browser.config
21-
browser.config.staticServer = { folder }
20+
browser.config.staticServer = {}
2221
}
2322

2423
if (!browser.config.staticServer.folder) {
25-
return
24+
const { folder } = browser.config
25+
if (!folder) {
26+
return
27+
}
28+
29+
browser.config.staticServer.folder = folder
2630
}
2731

2832
browser.hook('start:before', () => StaticServer.start(browser.config.staticServer, browser.config.quiet))

test/unit/command.static-server.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ describe('StaticServer', () => {
5050

5151
test('should load with boolean config', () => {
5252
const hook = jest.fn()
53-
StaticServer.load({
53+
const browser = {
5454
config: {
5555
folder: 'test',
5656
staticServer: true
5757
},
5858
hook
59-
})
59+
}
60+
StaticServer.load(browser)
6061

61-
expect(hook).toHaveBeenCalled()
62+
expect(hook).toHaveBeenCalledTimes(2)
63+
expect(browser.config.staticServer).toBeInstanceOf(Object)
64+
expect(browser.config.staticServer.folder).toBe('test')
6265
})
6366

6467
test('should load with browser config', () => {

0 commit comments

Comments
 (0)