Skip to content

Commit

Permalink
Added eslint-plugin-playwright to ensue tag convention (carbon-desi…
Browse files Browse the repository at this point in the history
…gn-system#15692)

* feat: added playwright checker

* fix: fixed ci

* fix: fixed RegExp

* fix: fixed name for the error in describe

* fix: yarn dedupe --strategy highest

* fix: fixed describe title
  • Loading branch information
guidari authored Feb 14, 2024
1 parent de4793c commit 667c2eb
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 5 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions config/eslint-config-carbon/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = {
require.resolve('./plugins/react'),
require.resolve('./plugins/storybook'),
require.resolve('./plugins/testing-library'),
require.resolve('./plugins/eslint-plugin-playwright'),
],
};
34 changes: 34 additions & 0 deletions config/eslint-config-carbon/plugins/eslint-plugin-playwright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const prefixes = [
'@avt-default-state',
'@avt-advanced-states',
'@avt-keyboard-nav',
];
const prefixesList = prefixes.join(' | \n');

module.exports = {
plugins: ['eslint-plugin-playwright'],
overrides: [
{
extends: ['plugin:playwright/recommended'],
files: ['*-test.avt.e2e.js'],
rules: {
'playwright/valid-title': [
'error',
{
mustMatch: {
describe: [
/^(\s*@avt(\s+\S+)*\s*)$/.source,
`Describe titles should start with "@avt" prefix`,
],
test: [
/^(\s*(@avt-default-state||@avt-advanced-states||@avt-keyboard-nav)(\s+\S+)*\s*)$/
.source,
`Test titles should start with one of the following prefixes: ${prefixesList}`,
],
},
},
],
},
},
],
};
2 changes: 1 addition & 1 deletion e2e/components/Accordion/Accordion-test.avt.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { expect, test } from '@playwright/test';
import { visitStory } from '../../test-utils/storybook';

test.describe('Accordion @avt', () => {
test.describe('@avt Accordion', () => {
test('@avt-default-state', async ({ page }) => {
await visitStory(page, {
component: 'Accordion',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"cross-spawn": "^7.0.0",
"doctoc": "^2.0.0",
"eslint": "^8.40.0",
"eslint-plugin-playwright": "^0.22.1",
"fs-extra": "^11.0.0",
"glob": "^10.0.0",
"husky": "^8.0.0",
Expand Down
24 changes: 20 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9937,6 +9937,7 @@ __metadata:
cross-spawn: "npm:^7.0.0"
doctoc: "npm:^2.0.0"
eslint: "npm:^8.40.0"
eslint-plugin-playwright: "npm:^0.22.1"
fs-extra: "npm:^11.0.0"
glob: "npm:^10.0.0"
husky: "npm:^8.0.0"
Expand Down Expand Up @@ -13354,6 +13355,21 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-playwright@npm:^0.22.1":
version: 0.22.1
resolution: "eslint-plugin-playwright@npm:0.22.1"
dependencies:
globals: "npm:^13.23.0"
peerDependencies:
eslint: ">=7"
eslint-plugin-jest: ">=25"
peerDependenciesMeta:
eslint-plugin-jest:
optional: true
checksum: 4833fe0c7b8bb1da9ecdff085011fbfb46b595b284453049c16be3f22fe329b05453f8ad57bcc001cda7495f96573a3f7df77d4e34b7d8a0f96d46f884ad460c
languageName: node
linkType: hard

"eslint-plugin-prettier@npm:^5.0.0":
version: 5.0.0
resolution: "eslint-plugin-prettier@npm:5.0.0"
Expand Down Expand Up @@ -15068,12 +15084,12 @@ __metadata:
languageName: node
linkType: hard

"globals@npm:^13.19.0":
version: 13.20.0
resolution: "globals@npm:13.20.0"
"globals@npm:^13.19.0, globals@npm:^13.23.0":
version: 13.24.0
resolution: "globals@npm:13.24.0"
dependencies:
type-fest: "npm:^0.20.2"
checksum: 9df85cde2f0dce6ac9b3a5e08bec109d2f3b38ddd055a83867e0672c55704866d53ce6a4265859fa630624baadd46f50ca38602a13607ad86be853a8c179d3e7
checksum: 62c5b1997d06674fc7191d3e01e324d3eda4d65ac9cc4e78329fa3b5c4fd42a0e1c8722822497a6964eee075255ce21ccf1eec2d83f92ef3f06653af4d0ee28e
languageName: node
linkType: hard

Expand Down

0 comments on commit 667c2eb

Please sign in to comment.