Have you ever run your e2e tests, only to find out 10, 15, or 30 minutes later that there was a missing/misspelled import, which didn't appear until the middle of the test run? When this happens, the test runner reports these tests as broken.
eslint is a great tool for catching different errors pre-runtime, and this service runs the eslint tool, prior to executing WebdriverIO tests, as an automated step instead of a manual one.
It's oftentimes better to fail faster so we can fix problems sooner rather than later.
Install the wdio-eslinter-service:
If you don't already have eslint installed and configured, you'll need to install it and configure it in your project:
.eslintrc.js in the root of your Node.js project:
By default, this minimal configuration checks for unresolved require imports and throws an error if unresolved imports are found. The service then stops execution. You can customize .eslintrc.js to perform more checks, if desired. See eslint for more details.
package.json, add this entry to your run scripts:
NOTE: Adding eslint to the package.json is required for the service to function.
Lastly, add the
eslinter service to the services array in
npm run eslint to verify and check for errors.
Start WebdriverIO's test runner as normal. eslint will check the code. If errors are found, execution immediately ceases.