-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(works): repeat a test as many times as necessary
- Loading branch information
Showing
5 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: node_js | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- '7' | ||
- '6' | ||
- '4' | ||
before_script: | ||
- npm prune | ||
after_success: | ||
- npm run semantic-release | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
'use strict' | ||
|
||
const oldIt = global.it | ||
console.assert(typeof oldIt === 'function', 'missing global it function') | ||
|
||
function repeatIt (times) { | ||
if (typeof times !== 'number') { | ||
// probably plain it('name', ...) call | ||
return oldIt.apply(null, arguments) | ||
} | ||
|
||
module.exports = true | ||
console.assert(times >= 0, 'repeat times should be non-negative') | ||
|
||
return function (title, fn) { | ||
let k | ||
for (k = 0; k < times; k += 1) { | ||
oldIt(k + 1 + ' ' + title, fn) | ||
} | ||
} | ||
} | ||
|
||
module.exports = repeatIt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
'use strict' | ||
|
||
|
||
/* eslint-env mocha */ | ||
const repeatIt = require('.') | ||
const it = require('.') | ||
|
||
describe('repeat-it', () => { | ||
it('write this test', () => { | ||
console.assert(repeatIt, 'should export something') | ||
let counter = 0 | ||
|
||
it(10)('repeated test', () => { | ||
counter += 1 | ||
}) | ||
|
||
after(() => { | ||
console.assert(counter === 10, 'runs ' + counter + ' times') | ||
}) | ||
}) |