-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurserrules.ts
More file actions
78 lines (69 loc) · 2.45 KB
/
curserrules.ts
File metadata and controls
78 lines (69 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* General coding rules for Curser when generating Playwright tests
*/
// ✅ Always use Playwright official documentation as the main reference.
// Docs: https://playwright.dev/docs
export const curserRules = {
// Test Design
testStructure: {
usePOM: true, // Use Page Object Model for all tests.
basePageUsage: true, // Use BasePage class for shared logic.
useHelperFunctions: true, // Break down complex logic into helper functions.
keepTestFileClean: true, // Do not write locators or logic in test file. Use POM only.
useDescribeBlocks: true,
preferDescriptiveTestNames: true,
},
// Locator Strategy
locatorStrategy: {
preferStableLocators: true, // Prefer 'getByTestId', 'getByRole', or data-testid.
avoidCssSelectors: true, // Do not use unstable selectors like .class or :nth-child.
useLocatorFilter: true, // Use .filter() or .nth() when needed to stabilize.
genericComponents: ['tableComponent', 'formComponent', 'modalComponent', 'navbarComponent'], // Use reusable components when possible
targetAttributes: ['data-testid', 'placeholder', 'aria-label', 'name', 'id']
},
generation: {
numberOfTestsPerPage: 2,
maxDomElementsToMap: 20
},
fileStructure: {
pageObjectsDir: "pages",
testsDir: "tests",
useKebabCaseForFiles: true,
},
// Code Style
codeStyle: {
useCamelCase: true, // Use camelCase for all variable and function names.
avoidLongFunctions: true, // Split large functions into smaller ones.
avoidComplexLogic: true, // Keep code easy to understand.
writeLikeSenior: true, // Write code like a Playwright automation engineer with 5 years of experience.
useSimpleEnglish: true, // Use simple and clear language in code and comments.
},
fileNaming: {
pageObjectSuffix: 'Page',
testFileSuffix: '.spec.ts',
outputFolderPO: 'pom',
outputFolderTests: 'tests',
},
// Secrets & Environment
secretsAndEnv: {
useSecretsFile: true, // Use a separate file for secrets and config.
secretsFileExample: {
url: 'https://example.com',
users: {
admin: {
email: 'admin@example.com',
password: 'securePassword123',
},
user: {
email: 'user@example.com',
password: 'userPassword456',
},
},
},
},
// Output Formatting
formatting: {
useSimpleComments: true, // Comments should be simple and helpful.
noAdvancedVocabulary: true, // Avoid complicated English words.
},
};