Gathering detailed insights and metrics for wdio-eslinter-service
Gathering detailed insights and metrics for wdio-eslinter-service
Gathering detailed insights and metrics for wdio-eslinter-service
Gathering detailed insights and metrics for wdio-eslinter-service
wdio-chromedriver-service
WebdriverIO service to start & stop ChromeDriver
@wdio/local-runner
A WebdriverIO runner to run tests locally
@wdio/utils
A WDIO helper utility to provide several utility functions used across the project.
wdio-intercept-service
Capture and assert HTTP ajax calls in webdriver.io 🕸
npm install wdio-eslinter-service
50.8
Supply Chain
90.4
Quality
70.8
Maintenance
100
Vulnerability
96.4
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1 Stars
15 Commits
2 Forks
2 Watching
2 Branches
2 Contributors
Updated on 03 Mar 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
18.3%
858
Compared to previous day
Last week
9.8%
4,927
Compared to previous week
Last month
5%
19,985
Compared to previous month
Last year
32.7%
238,627
Compared to previous year
4
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.
The recommended configuration is to use the unresolved runner to just check missing imports, but if desired, you can also configure the service to run the eslinter in your project using the npm or yarn runner, or by passing in a flag that tells the system to use your .eslintrc configuration as well.
Install the wdio-eslinter-service:
$ npm i wdio-eslinter-service --save-dev
By default, this minimal configuration, the "unresolved" runner, 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 using the "npm" or "yarn" runners, if desired. See eslint for more details.
If you don't have an .eslintrc.js
configuration in your project, then wdio-eslinter-service can be configured to use a default one which just checks for missing imports before running the tests. This is handy so that you find out about incorrect imports sooner rather than later. To configure this, add the following eslinter configuration to your services array (assuming you already are using the chromedriver service; otherwise, leave that part out):
wdio.conf.js:
services: ['chromedriver', [
'eslinter',
{
runnerType: 'unresolved'
}
]],
At this point, start running the tests, and if there is a missing or incorrect import, WebdriverIO will log it and immediately terminate the test run:
$ npx wdio
If you're using the module-alias module, which lets you configure aliases to replace relative paths, you'll need to pass that into the eslinter configuration using the eslint-import-resolver-custom-alias plugin. Below is an example:
services: ['chromedriver', [
'eslinter',
{
runnerType: 'unresolved',
eslintOverride: {
"settings": {
"import/resolver": {
"eslint-import-resolver-custom-alias": {
"alias": {
"@utils": "./utils",
"@specs": "./test-sync/specs",
"@pageobjects": "./test-sync/pageobjects",
"@": "./"
}
}
}
}
}
}
]],
Install the plugin in your project:
$ npm i eslint-import-resolver-custom-alias
Run the tests and verify the system will find incorrect imports that use module aliases:
$ npx wdio
To also have the eslinter service use an existing eslintrc configuration in your project, set includeProjectEslintrc
to true in the wdio.conf.js configuration services array.
I've experienced problems with conflicting plugins. If your project eslint setup is also looking for unresolved imports, then this may not work and may require adjustments to your .eslintrc.js. This is not recommended at this time.
The npm and yarn runners help give you additional control over running an existing eslinter setup in your project. With this configuration, you can define extra commands to run in the run-scripts section in your package.json:
Inside your package.json
, add this entry to your run scripts:
1{ 2 "scripts": { 3 "eslint": "eslint ." 4 } 5}
NOTE: Adding eslint to the package.json is required for the service to function when using the npm or yarn runners.
If you don't already have eslint installed and configured, you'll need to install it and configure it in your project, as well as any plugins you're using, such as eslint-plugin-import:
$ npm i eslint eslint-plugin-import
If you're using eslint-import-resolver-custom-alias plugin to map module aliases to their real paths, then you'll need to install it as well:
$ npm i eslint-import-resolver-custom-alias
You'll also need to create an .eslintrc.js
file, if you don't already have one of the eslintrc configuration files in your project. Here is a basic setup to just look for unresolved imports, and you can expand this configuration to validate other code quality checks before running tests:
// .eslintrc.js
module.exports = {
"parserOptions": {
"ecmaVersion": 2022
},
"plugins": [
"import"
],
"rules": {
"import/no-unresolved": [
2,
{
"commonjs": true,
"amd": false,
"caseSensitive": true
}
]
}
}
Lastly, add the eslinter
service to the services array in wdio.conf.js
:
1 services: ['eslinter']
Run npm run eslint
to verify and check for errors.
If you use yarn
you can configure the runnerType
service option:
1 services: [ 2 ['eslinter', { runnerType: 'yarn' }] 3 ]
If you already have a linter script that you would like to reuse (instead of eslint
), you can configure the scriptName
service option:
1 services: [ 2 ['eslinter', { scriptName: 'eslint:check' }] 3 ]
Start WebdriverIO's test runner as normal. eslint will check the code. If errors are found, execution immediately ceases.
1$ npx wdio
Example:
1$ npx wdio --spec ./test/specs/example.e2e.js 2 3Execution of 1 spec files started at 2021-05-15T12:04:05.388Z 4 52021-05-15T12:04:05.793Z WARN wdio-eslinter-service: initialize wdio-eslint-service using npm runner. 6Deleted files and directories: 7 /Users/jem/Dev/wdio-example/allure-results 8 9/Users/jem/Dev/wdio-example/test/specs/login.js 10 1:22 error Unable to resolve path to module '.../pageObjects/Auth.page' import/no-unresolved 11 12✖ 1 problem (1 error, 0 warnings) 13 142021-05-15T12:04:08.581Z ERROR wdio-eslinter-service: SEVERE: Code contains eslint errors or eslint not installed.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 1/12 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More