-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hope can support optional test #3592
Comments
Hello @bluelovers 👋 thanks for the suggestion, My thoughts on this: I am generally against having optional cases in the tests, I'd rather modify the assertion inside the case, or wrap the case in an |
Optional tests sounds weird, but I myself had had the occasion for them. In so far as I want to run some tests for certain environments. I've used tagging for this however and controlled that via the options. @Bamieh I wouldn't like to recommend any type of conditional logic in a test, as then one needs a test for the test :) |
any way make if one of current mocha test is fail, at end will not count mocha is fail |
Give example test for your problem, pls! |
hmm, my english enough for detail say what i mean for example i wanna run a mocha test when and i wanna if some of mocha test is fail , will not break script task a little like env chk https://node.green/ just wanna do some chk for see it is support or not in current env (by mocha) "scripts": {
"docs": "npx typedoc --options ./typedoc.config.js",
"local-delete-cache-db": "ts-node ./test/lib/delete-cache.ts",
"prepack": "echo prepack",
"postpack": "echo postpack",
"publish": "echo publish",
"postpublish": "echo postpublish && node ./script/publish-after",
"prepublishOnly": "npx npm-check-updates -u --packageFile ./package.json && npm run test",
"test": "npm run test-ts",
"test-js": "npx mocha \"!(node_modules)/**/*.+(test|spec).js\"",
"test-ts": "npx mocha --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
"travis": "typedoc --options ./typedoc.config.js"
}, |
None of what you've provided shows a test you are concerned about. Mocha will fail the run if any of your tests fail. If you need to conditionally skip a test at runtime (e.g., due to environment), do your check in |
Thanks for the suggestion. If you need to avoid a particular test in a particular environment, detect the environment, then conditionally call |
duplicate of probably other issues as well |
i don't wanna skip it, i wanna test it, but skip error for complete successfully, and will display error message |
Programmatically, you could probably change the |
i try add after(function ()
{
process.exitCode = 0
});
afterEach(function ()
{
process.exitCode = 0
}); it(args[0], function ()
{
let actual = Segment.stringify(doSegment(args[0]));
let expected = args[1];
console.debug(actual);
lazyMatchSynonym001(actual, expected, args[2]);
process.exitCode = 0
});
process.exitCode = 0
});
}); but still get |
Yeah, that's not programmatically though... See here. mocha.run(function(failures) {
process.exitCode = 0; // exit with zero status regardless of failures
}); |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
hope can support
optional test
when that
optional test
is fail, will only show notice, but not make currenttest suite
count asfail
Expected behavior: [What you expect to happen]
Actual behavior: [What actually happens]
Reproduces how often: [What percentage of the time does it reproduce?]
Versions
mocha --version
andnode node_modules/.bin/mocha --version
:node --version
:Additional Information
The text was updated successfully, but these errors were encountered: