Skip to content

Commit

Permalink
Disable no-await-in-loop for Playwright (#128)
Browse files Browse the repository at this point in the history
# Justification

#123 (won't mark it fixed until we uptake this in clients and remove
suppressions)

# Implementation

Add a rule configuration and docs to the `index.js` for the Playwright
ruleset.

# Testing

Built package locally, imported into an SLE codebase, and verified that
violations no longer need to be suppressed.

---------

Co-authored-by: Milan Raj <[email protected]>
  • Loading branch information
jattasNI and rajsite authored May 10, 2024
1 parent 3187bb3 commit 319b3ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ configure ESLint for Angular projects**.
Extend `@ni/eslint-config-playwright` and `@ni/eslint-config-playwright/requiring-type-checking` in the [ESLint configuration](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats). Set the `parserOptions.project` configuration to the project's TypeScript configuration.

**Note:** The Playwright configurations extend the TypeScript configurations, so it is not necessary for an application to extend them both.
**Note:** The Playwright configurations extend the TypeScript configurations, so it is not necessary for an application to extend them both. However, the Playwright configurations should only be applied to directories that contain Playwright tests and utilities.

```js
// This is an example .eslintrc.js in a Playwright-specific directory.
// If Playwright files are mixed with other code, use an "overrides" file pattern to match only Playwright code.
{
extends: [
'@ni/eslint-config-playwright',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Disable no-await-in-loop for Playwright",
"packageName": "@ni/eslint-config-playwright",
"email": "[email protected]",
"dependentChangeType": "patch"
}
8 changes: 8 additions & 0 deletions packages/eslint-config-playwright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ module.exports = {
'plugin:playwright/playwright-test'
],
rules: {
/*
In UI tests it is common to have a loop that performs async operations which must be sequential.
For example, clicking on a list of elements one after another.
While there are still some cases where the rule would suggest valid improvements, they are not common
enough to justify the noise that comes from needing to suppress it.
*/
'no-await-in-loop': 'off',

/*
Playwright marks this as recommended but configures it as 'warn'.
Deeply nested describe blocks are likely an indication that test files are too complicated.
Expand Down

0 comments on commit 319b3ba

Please sign in to comment.