Skip to content

Commit f591b21

Browse files
authored
Migrate away from deprecated function calls (#59)
* Migrate away from deprecated function calls * Remove unnecessary function wrapping
1 parent 5b50514 commit f591b21

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

src/runner/configureMocha.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ export default function configureMocha(options: MochaWebpackOptions) {
77
// infinite stack traces
88
Error.stackTraceLimit = Infinity
99

10+
const mochaOptions = {
11+
color: !!options.colors,
12+
inlineDiffs: !!options.useInlineDiffs
13+
}
14+
1015
// init mocha
11-
const mocha = new Mocha()
16+
const mocha = new Mocha(mochaOptions)
1217

1318
// reporter
1419
const reporter = loadReporter(options.reporter, options.cwd)
1520
mocha.reporter(reporter, options.reporterOptions)
1621

17-
// colors
18-
mocha.useColors(options.colors)
19-
20-
// inline-diffs
21-
mocha.useInlineDiffs(options.useInlineDiffs)
22-
2322
// slow <ms>
2423
mocha.suite.slow(options.slow)
2524

test/unit/runner/configureMocha.test.ts

+24-17
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ describe('configureMocha', function() {
2626
}
2727
this.sandbox = sandbox.create()
2828
this.spyReporter = this.sandbox.spy(Mocha.prototype, 'reporter')
29-
this.spyUseColors = this.sandbox.spy(Mocha.prototype, 'useColors')
30-
this.spyUseInlineDiffs = this.sandbox.spy(Mocha.prototype, 'useInlineDiffs')
3129
this.spyEnableTimeouts = this.sandbox.spy(Mocha.prototype, 'enableTimeouts')
3230
this.spyGrep = this.sandbox.spy(Mocha.prototype, 'grep')
3331
this.spyGrowl = this.sandbox.spy(Mocha.prototype, 'growl')
@@ -60,27 +58,36 @@ describe('configureMocha', function() {
6058
)
6159
})
6260

63-
it('should call useColors()', function() {
64-
configureMocha({
65-
...this.options
61+
it('should set color', function() {
62+
var mocha = configureMocha({
63+
...this.options,
64+
colors: undefined
6665
})
6766

68-
assert.isTrue(this.spyUseColors.called, 'useColors() should be called')
69-
assert.isTrue(this.spyUseColors.calledWith(this.options.colors))
67+
assert.isFalse(mocha.options.color)
68+
69+
mocha = configureMocha({
70+
...this.options,
71+
colors: true
72+
})
73+
74+
assert.isTrue(mocha.options.color)
7075
})
7176

72-
it('should call useInlineDiffs()', function() {
73-
configureMocha({
74-
...this.options
77+
it('should set inlineDiffs', function() {
78+
var mocha = configureMocha({
79+
...this.options,
80+
useInlineDiffs: undefined
7581
})
7682

77-
assert.isTrue(
78-
this.spyUseInlineDiffs.called,
79-
'useInlineDiffs() should be called'
80-
)
81-
assert.isTrue(
82-
this.spyUseInlineDiffs.calledWith(this.options.useInlineDiffs)
83-
)
83+
assert.isFalse(mocha.options.inlineDiffs)
84+
85+
mocha = configureMocha({
86+
...this.options,
87+
useInlineDiffs: true
88+
})
89+
90+
assert.isTrue(mocha.options.inlineDiffs)
8491
})
8592

8693
it('should call enableTimeouts()', function() {

0 commit comments

Comments
 (0)