I want to update my .eslintrc.js
to set up the rule that it requires a blank line between the test.beforeAll
, test.beforeEach
, test
, test.afterAll
, test.afterEach
in the test code using Playwright
// test-login.test.js
const { test, expect } = require('@playwright/test');
let context;
test.describe('test login', () => {
test.beforeAll(async ({ browser }) => {
context = await browser.newContext({ storageState: 'user1.json' });
});
test.beforeEach(async ({ browser }) => {
page = await context.newPage();
});
test.afterAll(async () => {
await context.close();
});
test.afterEach(async () => {
await context.close();
});
test('test login with valid account', async () => {
// test code...
});
test('test login with invalid account', async () => {
// test code...
});
test('test login with invalid password', async () => {
// test code...
});
});
I tried to set up the rule as following but it’s not working
// .eslintrc.js
module.exports = {
env: {
es2021: true,
node: true
},
extends: [
'eslint:recommended',
'google',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:playwright/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module'
},
root: true,
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'padding-line-between-statements': [
'warn',
{ blankLine: 'always', prev: '*', next: 'function' },
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'always', prev: '*', next: 'block' },
{ blankLine: 'always', prev: 'function', next: 'function' }
],
'@typescript-eslint/no-var-requires': 'off',
'playwright/no-wait-for-timeout': 'off',
'camelcase': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},
],
'prettier/prettier': [
'warn',
{
endOfLine: 'auto',
singleQuote: true,
parser: 'flow',
printWidth: 140
}
],
'new-cap': 'warn',
'max-len': 'off',
'valid-jsdoc': 'warn',
'require-jsdoc': 'off',
'linebreak-style': 'off',
'no-unused-vars': 'warn',
'spaced-comment': 'warn'
}
};