-
-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed pause finishing, added suggest for empty run, included fuse.js … (
#4713) * fixed pause finishing, added suggest for empty run, included fuse.js for better search * fixed test * updated plugins docs * improved unit tests setup * fixed interface test for CI mode * fixed on ci * added env variable config --------- Co-authored-by: DavertMik <[email protected]>
- Loading branch information
Showing
11 changed files
with
280 additions
and
153 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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const figures = require('figures') | ||
const Container = require('../container') | ||
const event = require('../event') | ||
const output = require('../output') | ||
|
||
module.exports = function () { | ||
let isEmptyRun = true | ||
|
||
event.dispatcher.on(event.test.before, test => { | ||
isEmptyRun = false | ||
}) | ||
|
||
event.dispatcher.on(event.all.result, () => { | ||
if (isEmptyRun) { | ||
const mocha = Container.mocha() | ||
|
||
if (mocha.options.grep) { | ||
const Fuse = require('fuse.js') | ||
|
||
output.print() | ||
output.print('No tests found by pattern: ' + mocha.options.grep) | ||
|
||
const allTests = [] | ||
mocha.suite.suites.forEach(suite => { | ||
suite.tests.forEach(test => { | ||
allTests.push(test.fullTitle()) | ||
}) | ||
}) | ||
|
||
const fuse = new Fuse(allTests, { | ||
includeScore: true, | ||
threshold: 0.6, | ||
caseSensitive: false, | ||
}) | ||
|
||
const results = fuse.search(mocha.options.grep.toString()) | ||
|
||
if (results.length > 0) { | ||
output.print() | ||
output.print('Maybe you wanted to run one of these tests?') | ||
results.forEach(result => { | ||
output.print(figures.checkboxOff, output.styles.log(result.item)) | ||
}) | ||
|
||
output.print() | ||
output.print(output.styles.debug('To run the first test use the following command:')) | ||
output.print(output.styles.bold('npx codeceptjs run --debug --grep "' + results[0].item + '"')) | ||
} | ||
} | ||
if (process.env.CI && !process.env.DONT_FAIL_ON_EMPTY_RUN) { | ||
output.print() | ||
output.error('No tests were executed. Failing on CI to avoid false positives') | ||
output.error('To disable this check, set `DONT_FAIL_ON_EMPTY_RUN` environment variable to true in CI config') | ||
process.exitCode = 1 | ||
} | ||
} | ||
}) | ||
} |
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
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
Oops, something went wrong.