1.0.2 • Published 4 years ago
eslint-plugin-detox-bcp v1.0.2
eslint-plugin-detox-bcp
Contains ESLint rules that may enforce current best practices for Detox.
Installation
You'll first need to install ESLint:
npm i eslint --save-devNext, install eslint-plugin-detox-bcp:
npm install eslint-plugin-detox-bcp --save-devUsage
Add detox to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"detox-bcp"
]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"detox-bcp/no-unhandled-catch": "error"
}
}or just use:
{
"extends": [
"plugin:detox-bcp/all"
]
}Supported Rules
detox-bcp/no-unhandled-catch
Prevents situations where the test writer always treats a caught error as a failed expectation or element action:
try {
await myTestDriver.tapOnNewButton();
} catch (e) {
// what if `e` is a SyntaxError or anything else?
await myTestDriver.tapOnOldButton();
}The rule enforces handling of the caught errors, e.g.:
try {
await myTestDriver.tapOnNewButton();
} catch (e) {
if (!`${e}`.match(/^DetoxRuntimeError.*visible/)) {
throw e;
}
await myTestDriver.tapOnOldButton();
}