Skip to content

Commit

Permalink
Migrate away from deprecated function calls (#59)
Browse files Browse the repository at this point in the history
* Migrate away from deprecated function calls

* Remove unnecessary function wrapping
  • Loading branch information
jayaddison authored Apr 13, 2020
1 parent 5b50514 commit f591b21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
13 changes: 6 additions & 7 deletions src/runner/configureMocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ export default function configureMocha(options: MochaWebpackOptions) {
// infinite stack traces
Error.stackTraceLimit = Infinity

const mochaOptions = {
color: !!options.colors,
inlineDiffs: !!options.useInlineDiffs
}

// init mocha
const mocha = new Mocha()
const mocha = new Mocha(mochaOptions)

// reporter
const reporter = loadReporter(options.reporter, options.cwd)
mocha.reporter(reporter, options.reporterOptions)

// colors
mocha.useColors(options.colors)

// inline-diffs
mocha.useInlineDiffs(options.useInlineDiffs)

// slow <ms>
mocha.suite.slow(options.slow)

Expand Down
41 changes: 24 additions & 17 deletions test/unit/runner/configureMocha.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ describe('configureMocha', function() {
}
this.sandbox = sandbox.create()
this.spyReporter = this.sandbox.spy(Mocha.prototype, 'reporter')
this.spyUseColors = this.sandbox.spy(Mocha.prototype, 'useColors')
this.spyUseInlineDiffs = this.sandbox.spy(Mocha.prototype, 'useInlineDiffs')
this.spyEnableTimeouts = this.sandbox.spy(Mocha.prototype, 'enableTimeouts')
this.spyGrep = this.sandbox.spy(Mocha.prototype, 'grep')
this.spyGrowl = this.sandbox.spy(Mocha.prototype, 'growl')
Expand Down Expand Up @@ -60,27 +58,36 @@ describe('configureMocha', function() {
)
})

it('should call useColors()', function() {
configureMocha({
...this.options
it('should set color', function() {
var mocha = configureMocha({
...this.options,
colors: undefined
})

assert.isTrue(this.spyUseColors.called, 'useColors() should be called')
assert.isTrue(this.spyUseColors.calledWith(this.options.colors))
assert.isFalse(mocha.options.color)

mocha = configureMocha({
...this.options,
colors: true
})

assert.isTrue(mocha.options.color)
})

it('should call useInlineDiffs()', function() {
configureMocha({
...this.options
it('should set inlineDiffs', function() {
var mocha = configureMocha({
...this.options,
useInlineDiffs: undefined
})

assert.isTrue(
this.spyUseInlineDiffs.called,
'useInlineDiffs() should be called'
)
assert.isTrue(
this.spyUseInlineDiffs.calledWith(this.options.useInlineDiffs)
)
assert.isFalse(mocha.options.inlineDiffs)

mocha = configureMocha({
...this.options,
useInlineDiffs: true
})

assert.isTrue(mocha.options.inlineDiffs)
})

it('should call enableTimeouts()', function() {
Expand Down

0 comments on commit f591b21

Please sign in to comment.