@toolstackhq/create-qa-patterns 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -10
- package/index.js +460 -1
- package/package.json +4 -3
- package/templates/playwright-template/.env.example +17 -0
- package/templates/playwright-template/.github/workflows/playwright-tests.yml +126 -0
- package/templates/playwright-template/README.md +234 -0
- package/templates/playwright-template/allurerc.mjs +10 -0
- package/templates/playwright-template/components/flash-message.ts +16 -0
- package/templates/playwright-template/config/environments.ts +41 -0
- package/templates/playwright-template/config/runtime-config.ts +53 -0
- package/templates/playwright-template/config/secret-manager.ts +28 -0
- package/templates/playwright-template/config/test-env.ts +9 -0
- package/templates/playwright-template/data/README.md +9 -0
- package/templates/playwright-template/data/factories/data-factory.ts +33 -0
- package/templates/playwright-template/data/generators/id-generator.ts +17 -0
- package/templates/playwright-template/data/generators/seeded-faker.ts +13 -0
- package/templates/playwright-template/docker/Dockerfile +21 -0
- package/templates/playwright-template/eslint.config.mjs +66 -0
- package/templates/playwright-template/fixtures/test-fixtures.ts +43 -0
- package/templates/playwright-template/lint/architecture-plugin.cjs +118 -0
- package/templates/playwright-template/package-lock.json +4724 -0
- package/templates/playwright-template/package.json +34 -0
- package/templates/playwright-template/pages/base-page.ts +24 -0
- package/templates/playwright-template/pages/login-page.ts +22 -0
- package/templates/playwright-template/pages/people-page.ts +39 -0
- package/templates/playwright-template/playwright.config.ts +46 -0
- package/templates/playwright-template/reporters/structured-reporter.ts +61 -0
- package/templates/playwright-template/scripts/generate-allure-report.mjs +57 -0
- package/templates/playwright-template/scripts/run-tests.sh +6 -0
- package/templates/playwright-template/tests/api-people.spec.ts +28 -0
- package/templates/playwright-template/tests/ui-journey.spec.ts +30 -0
- package/templates/playwright-template/tsconfig.json +31 -0
- package/templates/playwright-template/utils/logger.ts +55 -0
- package/templates/playwright-template/utils/test-step.ts +22 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const TEST_FILE_PATTERN = /[/\\]tests[/\\].+\.ts$/;
|
|
2
|
+
const PAGE_OBJECT_PATTERN = /[/\\](pages|components)[/\\].+\.ts$/;
|
|
3
|
+
|
|
4
|
+
const locatorMethods = new Set([
|
|
5
|
+
"locator",
|
|
6
|
+
"getByRole",
|
|
7
|
+
"getByLabel",
|
|
8
|
+
"getByTestId",
|
|
9
|
+
"getByText",
|
|
10
|
+
"getByPlaceholder",
|
|
11
|
+
"getByAltText",
|
|
12
|
+
"getByTitle",
|
|
13
|
+
"$",
|
|
14
|
+
"$$"
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
function isIdentifierProperty(node, name) {
|
|
18
|
+
return (
|
|
19
|
+
node &&
|
|
20
|
+
node.type === "MemberExpression" &&
|
|
21
|
+
!node.computed &&
|
|
22
|
+
node.property &&
|
|
23
|
+
node.property.type === "Identifier" &&
|
|
24
|
+
node.property.name === name
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
rules: {
|
|
30
|
+
"no-raw-locators-in-tests": {
|
|
31
|
+
meta: {
|
|
32
|
+
type: "problem",
|
|
33
|
+
docs: {
|
|
34
|
+
description: "Disallow selectors inside test files"
|
|
35
|
+
},
|
|
36
|
+
schema: [],
|
|
37
|
+
messages: {
|
|
38
|
+
noRawLocators:
|
|
39
|
+
"Raw locators are not allowed in tests. Move selector logic into a page object or component."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
create(context) {
|
|
43
|
+
if (!TEST_FILE_PATTERN.test(context.getFilename())) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
CallExpression(node) {
|
|
49
|
+
if (
|
|
50
|
+
node.callee.type === "MemberExpression" &&
|
|
51
|
+
!node.callee.computed &&
|
|
52
|
+
node.callee.property.type === "Identifier" &&
|
|
53
|
+
locatorMethods.has(node.callee.property.name)
|
|
54
|
+
) {
|
|
55
|
+
context.report({
|
|
56
|
+
node,
|
|
57
|
+
messageId: "noRawLocators"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"no-wait-for-timeout": {
|
|
65
|
+
meta: {
|
|
66
|
+
type: "problem",
|
|
67
|
+
docs: {
|
|
68
|
+
description: "Disallow waitForTimeout"
|
|
69
|
+
},
|
|
70
|
+
schema: [],
|
|
71
|
+
messages: {
|
|
72
|
+
noWaitForTimeout: "waitForTimeout is not allowed. Synchronize with user-visible events instead."
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
create(context) {
|
|
76
|
+
return {
|
|
77
|
+
CallExpression(node) {
|
|
78
|
+
if (isIdentifierProperty(node.callee, "waitForTimeout")) {
|
|
79
|
+
context.report({
|
|
80
|
+
node,
|
|
81
|
+
messageId: "noWaitForTimeout"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"no-expect-in-page-objects": {
|
|
89
|
+
meta: {
|
|
90
|
+
type: "problem",
|
|
91
|
+
docs: {
|
|
92
|
+
description: "Disallow assertions inside page objects and UI components"
|
|
93
|
+
},
|
|
94
|
+
schema: [],
|
|
95
|
+
messages: {
|
|
96
|
+
noExpect:
|
|
97
|
+
"Assertions are not allowed inside page objects or components. Return state and assert from the test."
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
create(context) {
|
|
101
|
+
if (!PAGE_OBJECT_PATTERN.test(context.getFilename())) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
CallExpression(node) {
|
|
107
|
+
if (node.callee.type === "Identifier" && node.callee.name === "expect") {
|
|
108
|
+
context.report({
|
|
109
|
+
node,
|
|
110
|
+
messageId: "noExpect"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|