angular-uitest 1.0.3

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.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +336 -0
  3. package/bin/samaro-allure.mjs +178 -0
  4. package/bin/samaro-init.mjs +407 -0
  5. package/bin/samaro-test.mjs +119 -0
  6. package/dist/cjs/config/index.d.ts +4 -0
  7. package/dist/cjs/config/index.d.ts.map +1 -0
  8. package/dist/cjs/config/index.js +11 -0
  9. package/dist/cjs/config/index.js.map +1 -0
  10. package/dist/cjs/config/playwright.component.config.d.ts +12 -0
  11. package/dist/cjs/config/playwright.component.config.d.ts.map +1 -0
  12. package/dist/cjs/config/playwright.component.config.js +42 -0
  13. package/dist/cjs/config/playwright.component.config.js.map +1 -0
  14. package/dist/cjs/config/playwright.config.d.ts +14 -0
  15. package/dist/cjs/config/playwright.config.d.ts.map +1 -0
  16. package/dist/cjs/config/playwright.config.js +53 -0
  17. package/dist/cjs/config/playwright.config.js.map +1 -0
  18. package/dist/cjs/config/vitest.config.d.ts +12 -0
  19. package/dist/cjs/config/vitest.config.d.ts.map +1 -0
  20. package/dist/cjs/config/vitest.config.js +60 -0
  21. package/dist/cjs/config/vitest.config.js.map +1 -0
  22. package/dist/cjs/helpers/allure.d.ts +141 -0
  23. package/dist/cjs/helpers/allure.d.ts.map +1 -0
  24. package/dist/cjs/helpers/allure.js +331 -0
  25. package/dist/cjs/helpers/allure.js.map +1 -0
  26. package/dist/cjs/helpers/api.d.ts +69 -0
  27. package/dist/cjs/helpers/api.d.ts.map +1 -0
  28. package/dist/cjs/helpers/api.js +163 -0
  29. package/dist/cjs/helpers/api.js.map +1 -0
  30. package/dist/cjs/helpers/auth.d.ts +35 -0
  31. package/dist/cjs/helpers/auth.d.ts.map +1 -0
  32. package/dist/cjs/helpers/auth.js +104 -0
  33. package/dist/cjs/helpers/auth.js.map +1 -0
  34. package/dist/cjs/helpers/config.d.ts +34 -0
  35. package/dist/cjs/helpers/config.d.ts.map +1 -0
  36. package/dist/cjs/helpers/config.js +70 -0
  37. package/dist/cjs/helpers/config.js.map +1 -0
  38. package/dist/cjs/helpers/debug.d.ts +48 -0
  39. package/dist/cjs/helpers/debug.d.ts.map +1 -0
  40. package/dist/cjs/helpers/debug.js +86 -0
  41. package/dist/cjs/helpers/debug.js.map +1 -0
  42. package/dist/cjs/helpers/index.d.ts +8 -0
  43. package/dist/cjs/helpers/index.d.ts.map +1 -0
  44. package/dist/cjs/helpers/index.js +76 -0
  45. package/dist/cjs/helpers/index.js.map +1 -0
  46. package/dist/cjs/helpers/setup.d.ts +50 -0
  47. package/dist/cjs/helpers/setup.d.ts.map +1 -0
  48. package/dist/cjs/helpers/setup.js +137 -0
  49. package/dist/cjs/helpers/setup.js.map +1 -0
  50. package/dist/cjs/src/index.d.ts +17 -0
  51. package/dist/cjs/src/index.d.ts.map +1 -0
  52. package/dist/cjs/src/index.js +99 -0
  53. package/dist/cjs/src/index.js.map +1 -0
  54. package/dist/esm/config/index.d.ts +4 -0
  55. package/dist/esm/config/index.d.ts.map +1 -0
  56. package/dist/esm/config/index.mjs +4 -0
  57. package/dist/esm/config/index.mjs.map +1 -0
  58. package/dist/esm/config/playwright.component.config.d.ts +12 -0
  59. package/dist/esm/config/playwright.component.config.d.ts.map +1 -0
  60. package/dist/esm/config/playwright.component.config.mjs +39 -0
  61. package/dist/esm/config/playwright.component.config.mjs.map +1 -0
  62. package/dist/esm/config/playwright.config.d.ts +14 -0
  63. package/dist/esm/config/playwright.config.d.ts.map +1 -0
  64. package/dist/esm/config/playwright.config.mjs +50 -0
  65. package/dist/esm/config/playwright.config.mjs.map +1 -0
  66. package/dist/esm/config/vitest.config.d.ts +12 -0
  67. package/dist/esm/config/vitest.config.d.ts.map +1 -0
  68. package/dist/esm/config/vitest.config.mjs +56 -0
  69. package/dist/esm/config/vitest.config.mjs.map +1 -0
  70. package/dist/esm/helpers/allure.d.ts +141 -0
  71. package/dist/esm/helpers/allure.d.ts.map +1 -0
  72. package/dist/esm/helpers/allure.mjs +306 -0
  73. package/dist/esm/helpers/allure.mjs.map +1 -0
  74. package/dist/esm/helpers/api.d.ts +69 -0
  75. package/dist/esm/helpers/api.d.ts.map +1 -0
  76. package/dist/esm/helpers/api.mjs +154 -0
  77. package/dist/esm/helpers/api.mjs.map +1 -0
  78. package/dist/esm/helpers/auth.d.ts +35 -0
  79. package/dist/esm/helpers/auth.d.ts.map +1 -0
  80. package/dist/esm/helpers/auth.mjs +96 -0
  81. package/dist/esm/helpers/auth.mjs.map +1 -0
  82. package/dist/esm/helpers/config.d.ts +34 -0
  83. package/dist/esm/helpers/config.d.ts.map +1 -0
  84. package/dist/esm/helpers/config.mjs +63 -0
  85. package/dist/esm/helpers/config.mjs.map +1 -0
  86. package/dist/esm/helpers/debug.d.ts +48 -0
  87. package/dist/esm/helpers/debug.d.ts.map +1 -0
  88. package/dist/esm/helpers/debug.mjs +76 -0
  89. package/dist/esm/helpers/debug.mjs.map +1 -0
  90. package/dist/esm/helpers/index.d.ts +8 -0
  91. package/dist/esm/helpers/index.d.ts.map +1 -0
  92. package/dist/esm/helpers/index.mjs +19 -0
  93. package/dist/esm/helpers/index.mjs.map +1 -0
  94. package/dist/esm/helpers/setup.d.ts +50 -0
  95. package/dist/esm/helpers/setup.d.ts.map +1 -0
  96. package/dist/esm/helpers/setup.mjs +95 -0
  97. package/dist/esm/helpers/setup.mjs.map +1 -0
  98. package/dist/esm/src/index.d.ts +17 -0
  99. package/dist/esm/src/index.d.ts.map +1 -0
  100. package/dist/esm/src/index.mjs +40 -0
  101. package/dist/esm/src/index.mjs.map +1 -0
  102. package/dist/types/config/index.d.ts +4 -0
  103. package/dist/types/config/index.d.ts.map +1 -0
  104. package/dist/types/config/playwright.component.config.d.ts +12 -0
  105. package/dist/types/config/playwright.component.config.d.ts.map +1 -0
  106. package/dist/types/config/playwright.config.d.ts +14 -0
  107. package/dist/types/config/playwright.config.d.ts.map +1 -0
  108. package/dist/types/config/vitest.config.d.ts +12 -0
  109. package/dist/types/config/vitest.config.d.ts.map +1 -0
  110. package/dist/types/helpers/allure.d.ts +141 -0
  111. package/dist/types/helpers/allure.d.ts.map +1 -0
  112. package/dist/types/helpers/api.d.ts +69 -0
  113. package/dist/types/helpers/api.d.ts.map +1 -0
  114. package/dist/types/helpers/auth.d.ts +35 -0
  115. package/dist/types/helpers/auth.d.ts.map +1 -0
  116. package/dist/types/helpers/config.d.ts +34 -0
  117. package/dist/types/helpers/config.d.ts.map +1 -0
  118. package/dist/types/helpers/debug.d.ts +48 -0
  119. package/dist/types/helpers/debug.d.ts.map +1 -0
  120. package/dist/types/helpers/index.d.ts +8 -0
  121. package/dist/types/helpers/index.d.ts.map +1 -0
  122. package/dist/types/helpers/setup.d.ts +50 -0
  123. package/dist/types/helpers/setup.d.ts.map +1 -0
  124. package/dist/types/src/index.d.ts +17 -0
  125. package/dist/types/src/index.d.ts.map +1 -0
  126. package/package.json +140 -0
  127. package/schematics/collection.json +11 -0
  128. package/schematics/ng-add/index.js +126 -0
  129. package/schematics/ng-add/schema.json +26 -0
  130. package/scripts/check-allure-results.mjs +300 -0
  131. package/scripts/rename-esm-files.mjs +76 -0
  132. package/types/allure.d.ts +76 -0
  133. package/types/global.d.ts +49 -0
@@ -0,0 +1,407 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ const colors = {
11
+ reset: '\x1b[0m',
12
+ bright: '\x1b[1m',
13
+ green: '\x1b[32m',
14
+ yellow: '\x1b[33m',
15
+ blue: '\x1b[34m',
16
+ cyan: '\x1b[36m',
17
+ red: '\x1b[31m',
18
+ };
19
+
20
+ function log(message, color = 'reset') {
21
+ console.log(`${colors[color]}${message}${colors.reset}`);
22
+ }
23
+
24
+ function createDirectory(dirPath) {
25
+ if (!fs.existsSync(dirPath)) {
26
+ fs.mkdirSync(dirPath, { recursive: true });
27
+ log(` ✓ Created ${dirPath}/`, 'green');
28
+ } else {
29
+ log(` ⚠ ${dirPath}/ already exists`, 'yellow');
30
+ }
31
+ }
32
+
33
+ function writeFile(filePath, content) {
34
+ try {
35
+ fs.writeFileSync(filePath, content);
36
+ log(` ✓ Created ${path.basename(filePath)}`, 'green');
37
+ } catch (error) {
38
+ log(` ✗ Failed to create ${path.basename(filePath)}: ${error.message}`, 'red');
39
+ }
40
+ }
41
+
42
+ function checkConflictingDependencies() {
43
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
44
+ if (!fs.existsSync(packageJsonPath)) {
45
+ log('⚠ No package.json found. Make sure you run this in an Angular project.', 'yellow');
46
+ return;
47
+ }
48
+
49
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
50
+ const conflicts = [];
51
+
52
+ const testingPackages = ['jest', 'karma', 'jasmine-core', 'protractor'];
53
+
54
+ const allDeps = {
55
+ ...packageJson.dependencies,
56
+ ...packageJson.devDependencies,
57
+ };
58
+
59
+ for (const pkg of testingPackages) {
60
+ if (allDeps[pkg]) {
61
+ conflicts.push(pkg);
62
+ }
63
+ }
64
+
65
+ if (conflicts.length > 0) {
66
+ log(`\n⚠️ Warning: Found potentially conflicting packages: ${conflicts.join(', ')}`, 'yellow');
67
+ log('You may need to remove these or configure them to work together.\n', 'yellow');
68
+ }
69
+ }
70
+
71
+ function detectWorkspace() {
72
+ if (fs.existsSync('nx.json')) return 'nx';
73
+ if (fs.existsSync('lerna.json')) return 'lerna';
74
+ if (fs.existsSync('pnpm-workspace.yaml')) return 'pnpm';
75
+ return 'standard';
76
+ }
77
+
78
+ async function initProject() {
79
+ log('\n🚀 Initializing SamaroUItest in your project...\n', 'bright');
80
+
81
+ const projectRoot = process.cwd();
82
+ const workspaceType = detectWorkspace();
83
+
84
+ if (workspaceType !== 'standard') {
85
+ log(`Detected ${workspaceType} workspace. Applying workspace-specific configuration...\n`, 'cyan');
86
+ }
87
+
88
+ // Check for conflicting dependencies
89
+ checkConflictingDependencies();
90
+
91
+ // Create directories
92
+ log('Creating directories...', 'cyan');
93
+ createDirectory(path.join(projectRoot, 'e2e'));
94
+ createDirectory(path.join(projectRoot, 'e2e', 'helpers'));
95
+ createDirectory(path.join(projectRoot, 'ct-tests'));
96
+
97
+ // Create configuration files
98
+ log('\nCreating configuration files...', 'cyan');
99
+
100
+ // Create vitest.config.ts with proper import.meta.url handling
101
+ writeFile(
102
+ path.join(projectRoot, 'vitest.config.ts'),
103
+ `import { createVitestConfig } from 'angular-uitest/config';
104
+ import { fileURLToPath } from 'url';
105
+ import { dirname } from 'path';
106
+
107
+ const __filename = fileURLToPath(import.meta.url);
108
+ const __dirname = dirname(__filename);
109
+
110
+ export default createVitestConfig({
111
+ projectRoot: __dirname,
112
+ testGlob: 'src/**/*.spec.ts',
113
+ resultsDir: 'allure-unit-results',
114
+ });
115
+ `
116
+ );
117
+
118
+ // Create playwright.config.ts
119
+ writeFile(
120
+ path.join(projectRoot, 'playwright.config.ts'),
121
+ `import { createPlaywrightConfig } from 'angular-uitest/config';
122
+
123
+ export default createPlaywrightConfig({
124
+ baseURL: 'http://localhost:4200',
125
+ testDir: './e2e',
126
+ resultsDir: 'allure-e2e-results',
127
+ webServerCommand: 'npm run start',
128
+ webServerPort: 4200,
129
+ });
130
+ `
131
+ );
132
+
133
+ // Create playwright.component.config.ts
134
+ writeFile(
135
+ path.join(projectRoot, 'playwright.component.config.ts'),
136
+ `import { createComponentConfig } from 'angular-uitest/config';
137
+
138
+ export default createComponentConfig({
139
+ baseURL: 'http://localhost:4200',
140
+ testDir: './ct-tests',
141
+ resultsDir: 'allure-ct-results',
142
+ });
143
+ `
144
+ );
145
+
146
+ // Create src/test-setup.ts if src directory exists
147
+ const srcDir = path.join(projectRoot, 'src');
148
+ if (fs.existsSync(srcDir)) {
149
+ writeFile(
150
+ path.join(srcDir, 'test-setup.ts'),
151
+ `import 'zone.js';
152
+ import 'zone.js/testing';
153
+ import { getTestBed } from '@angular/core/testing';
154
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
155
+
156
+ getTestBed().initTestEnvironment(
157
+ BrowserDynamicTestingModule,
158
+ platformBrowserDynamicTesting()
159
+ );
160
+ `
161
+ );
162
+ }
163
+
164
+ // Create example test files with Allure metadata
165
+ log('\nCreating example test files with Allure metadata...', 'cyan');
166
+
167
+ // Example E2E test with Allure annotations
168
+ writeFile(
169
+ path.join(projectRoot, 'e2e', 'example.spec.ts'),
170
+ `import { test, expect } from '@playwright/test';
171
+ import {
172
+ generateUniqueUser,
173
+ register,
174
+ severity,
175
+ tag,
176
+ epic,
177
+ feature,
178
+ story,
179
+ owner,
180
+ description,
181
+ issue,
182
+ allureStep,
183
+ attachScreenshot
184
+ } from 'angular-uitest/helpers';
185
+
186
+ test.describe('Example Tests', () => {
187
+
188
+ test('homepage has title', async ({ page }) => {
189
+ // Allure metadata using test.info()
190
+ test.info().severity = 'normal';
191
+ test.info().tags = ['smoke', 'regression'];
192
+
193
+ await allureStep('Navigate to homepage', async () => {
194
+ await page.goto('/');
195
+ });
196
+
197
+ await allureStep('Verify page title', async () => {
198
+ await expect(page).toHaveTitle(/Angular/);
199
+ });
200
+ });
201
+
202
+ test('user can register', async ({ page }) => {
203
+ // Allure metadata
204
+ test.info().severity = 'critical';
205
+ test.info().tags = ['user-management', 'positive'];
206
+
207
+ const user = generateUniqueUser();
208
+
209
+ await allureStep('Register new user', async () => {
210
+ await register(page, user.username, user.email, user.password);
211
+ });
212
+
213
+ await allureStep('Verify successful registration', async () => {
214
+ await expect(page).toHaveURL('/');
215
+ });
216
+
217
+ // Attach screenshot on success
218
+ await attachScreenshot('Registration success', page);
219
+ });
220
+
221
+ test('login form validation', async ({ page }) => {
222
+ test.info().severity = 'minor';
223
+ test.info().tags = ['validation', 'negative'];
224
+
225
+ await allureStep('Navigate to login', async () => {
226
+ await page.goto('/login');
227
+ });
228
+
229
+ await allureStep('Submit empty form', async () => {
230
+ await page.click('button[type="submit"]');
231
+ });
232
+
233
+ await allureStep('Verify validation errors', async () => {
234
+ await expect(page.locator('.error-message')).toBeVisible();
235
+ });
236
+ });
237
+ });
238
+ `
239
+ );
240
+
241
+ // Example component test with Allure annotations
242
+ writeFile(
243
+ path.join(projectRoot, 'ct-tests', 'example.spec.ts'),
244
+ `import { test, expect } from '@playwright/test';
245
+ import {
246
+ severity,
247
+ tag,
248
+ allureStep,
249
+ attachScreenshot
250
+ } from 'angular-uitest/helpers';
251
+
252
+ test.describe('Component Example', () => {
253
+
254
+ test('renders component', async ({ page }) => {
255
+ test.info().severity = 'normal';
256
+ test.info().tags = ['component', 'ui'];
257
+
258
+ await allureStep('Navigate to component', async () => {
259
+ await page.goto('/');
260
+ });
261
+
262
+ await allureStep('Verify component is visible', async () => {
263
+ await expect(page.locator('app-root')).toBeVisible();
264
+ });
265
+
266
+ await attachScreenshot('Component rendered', page);
267
+ });
268
+
269
+ test('component interactions', async ({ page }) => {
270
+ test.info().severity = 'critical';
271
+ test.info().tags = ['component', 'interaction'];
272
+
273
+ await allureStep('Navigate to component', async () => {
274
+ await page.goto('/');
275
+ });
276
+
277
+ await allureStep('Interact with component', async () => {
278
+ // Add interaction steps here
279
+ await page.waitForTimeout(1000);
280
+ });
281
+
282
+ await allureStep('Verify interaction result', async () => {
283
+ await expect(page.locator('app-root')).toBeVisible();
284
+ });
285
+ });
286
+ });
287
+ `
288
+ );
289
+
290
+ // Example unit test file
291
+ writeFile(
292
+ path.join(projectRoot, 'src', 'app', 'example.spec.ts'),
293
+ `import { describe, it, expect } from 'vitest';
294
+ import {
295
+ severity,
296
+ tag,
297
+ description
298
+ } from 'angular-uitest/helpers';
299
+
300
+ describe('Example Unit Tests', () => {
301
+
302
+ it('should perform basic calculation', () => {
303
+ // Add Allure metadata using comments or decorators
304
+ const result = 2 + 2;
305
+ expect(result).toBe(4);
306
+ });
307
+
308
+ it('should handle strings correctly', () => {
309
+ const text = 'Hello, Samaro!';
310
+ expect(text).toContain('Samaro');
311
+ });
312
+
313
+ it('should work with arrays', () => {
314
+ const arr = [1, 2, 3];
315
+ expect(arr).toHaveLength(3);
316
+ expect(arr).toContain(2);
317
+ });
318
+ });
319
+ `
320
+ );
321
+
322
+ // Update package.json scripts
323
+ log('\nUpdating package.json scripts...', 'cyan');
324
+ const packageJsonPath = path.join(projectRoot, 'package.json');
325
+
326
+ if (fs.existsSync(packageJsonPath)) {
327
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
328
+
329
+ packageJson.scripts = {
330
+ ...packageJson.scripts,
331
+ 'test': 'samaro-test vitest',
332
+ 'test:run': 'samaro-test "vitest --run"',
333
+ 'test:ui': 'samaro-test "vitest --ui"',
334
+ 'test:coverage': 'samaro-test "vitest --coverage"',
335
+ 'test:e2e': 'samaro-test "playwright test"',
336
+ 'test:e2e:ui': 'samaro-test "playwright test --ui"',
337
+ 'test:e2e:headed': 'samaro-test "playwright test --headed"',
338
+ 'test:e2e:debug': 'samaro-test "playwright test --debug"',
339
+ 'test:ct': 'samaro-test "playwright test --config playwright.component.config.ts"',
340
+ 'test:ct:ui': 'samaro-test "playwright test --config playwright.component.config.ts --ui"',
341
+ 'allure:generate': 'samaro-allure generate',
342
+ 'allure:open': 'samaro-allure open',
343
+ 'allure:clean': 'samaro-allure clean',
344
+ 'allure:serve': 'npm run allure:generate && npm run allure:open',
345
+ };
346
+
347
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
348
+ log(' ✓ Updated package.json', 'green');
349
+ }
350
+
351
+ // Create .gitignore entries
352
+ log('\nUpdating .gitignore...', 'cyan');
353
+ const gitignorePath = path.join(projectRoot, '.gitignore');
354
+ const gitignoreEntries = [
355
+ '\n# SamaroUItest',
356
+ 'allure-*-results/',
357
+ 'allure-reports/',
358
+ 'playwright-report/',
359
+ 'playwright-component-report/',
360
+ 'test-results/',
361
+ 'coverage/',
362
+ ];
363
+
364
+ if (fs.existsSync(gitignorePath)) {
365
+ const gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
366
+ if (!gitignoreContent.includes('SamaroUItest')) {
367
+ fs.appendFileSync(gitignorePath, gitignoreEntries.join('\n'));
368
+ log(' ✓ Updated .gitignore', 'green');
369
+ } else {
370
+ log(' ⚠ .gitignore already contains SamaroUItest entries', 'yellow');
371
+ }
372
+ } else {
373
+ fs.writeFileSync(gitignorePath, gitignoreEntries.join('\n'));
374
+ log(' ✓ Created .gitignore', 'green');
375
+ }
376
+
377
+ log('\n' + '='.repeat(60), 'cyan');
378
+ log('✅ Initialization complete!', 'green');
379
+ log('='.repeat(60), 'cyan');
380
+
381
+ log('\n📋 Next steps:', 'bright');
382
+ log(' 1. Install dependencies: npm install', 'yellow');
383
+ log(' 2. Install Playwright: npx playwright install chromium', 'yellow');
384
+ log(' 3. Run unit tests: npm run test', 'yellow');
385
+ log(' 4. Run E2E tests: npm run test:e2e', 'yellow');
386
+ log(' 5. Generate reports: npm run allure:generate', 'yellow');
387
+ log(' 6. View reports: npm run allure:open\n', 'yellow');
388
+
389
+ log('📚 Documentation:', 'bright');
390
+ log(' - https://github.com/samaro/angular-uitest#readme\n', 'blue');
391
+
392
+ log('🎯 Allure Features Available:', 'bright');
393
+ log(' • Severity levels (blocker, critical, normal, minor, trivial)', 'cyan');
394
+ log(' • Tags and labels for categorization', 'cyan');
395
+ log(' • Test steps for detailed reporting', 'cyan');
396
+ log(' • Screenshots and attachments', 'cyan');
397
+ log(' • Epic/Feature/Story hierarchy', 'cyan');
398
+ log(' • Issue and TMS links\n', 'cyan');
399
+ }
400
+
401
+ // Run initialization
402
+ try {
403
+ await initProject();
404
+ } catch (error) {
405
+ console.error('❌ Initialization failed:', error);
406
+ process.exit(1);
407
+ }
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'cross-spawn';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import fs from 'fs';
7
+
8
+ /**
9
+ * Detect if running in a CI environment
10
+ * Checks for common CI environment variables
11
+ */
12
+ function isCIEnvironment() {
13
+ const ciEnvVars = [
14
+ 'CI',
15
+ 'CONTINUOUS_INTEGRATION',
16
+ 'BUILD_NUMBER',
17
+ 'BUILD_ID',
18
+ 'TEAMCITY_VERSION',
19
+ 'TRAVIS',
20
+ 'CIRCLECI',
21
+ 'GITHUB_ACTIONS',
22
+ 'GITLAB_CI',
23
+ 'JENKINS_URL',
24
+ 'JENKINS_HOME',
25
+ 'HUDSON_URL',
26
+ 'DRONE',
27
+ 'APPVEYOR',
28
+ 'CODEBUILD_BUILD_ID',
29
+ 'TF_BUILD',
30
+ 'BITBUCKET_PIPELINE_UUID',
31
+ 'BAMBOO_PLAN_KEY',
32
+ 'GOCD_SERVER_URL',
33
+ ];
34
+
35
+ return ciEnvVars.some((envVar) => process.env[envVar]) || process.env.SAMARO_AUTO_CLEAN;
36
+ }
37
+
38
+ const __filename = fileURLToPath(import.meta.url);
39
+ const __dirname = path.dirname(__filename);
40
+
41
+ // Try multiple locations for the check-allure-results script
42
+ const possibleScriptPaths = [
43
+ path.join(__dirname, '..', 'scripts', 'check-allure-results.mjs'),
44
+ path.join(__dirname, '..', 'dist', 'scripts', 'check-allure-results.mjs'),
45
+ path.join(process.cwd(), 'node_modules', 'angular-uitest', 'scripts', 'check-allure-results.mjs'),
46
+ ];
47
+
48
+ let checkAllureScript = possibleScriptPaths.find(p => fs.existsSync(p));
49
+
50
+ // If not found, use the first path (will fail with meaningful error)
51
+ if (!checkAllureScript) {
52
+ checkAllureScript = possibleScriptPaths[0];
53
+ }
54
+
55
+ const args = process.argv.slice(2);
56
+
57
+ if (args.length === 0) {
58
+ console.error('❌ Error: No test command provided');
59
+ console.error('Usage: samaro-test "<test-command>"');
60
+ console.error('');
61
+ console.error('Examples:');
62
+ console.error(' samaro-test vitest');
63
+ console.error(' samaro-test "vitest --run"');
64
+ console.error(' samaro-test "playwright test"');
65
+ console.error('');
66
+ console.error('Environment Variables:');
67
+ console.error(' CI=true Run in CI mode (auto-clean without prompts)');
68
+ console.error(' SAMARO_AUTO_CLEAN=1 Auto-clean Allure results without prompts');
69
+ process.exit(1);
70
+ }
71
+
72
+ const command = args.join(' ');
73
+
74
+ // Detect if running in CI mode (auto-detect common CI environments)
75
+ const isCI = isCIEnvironment();
76
+
77
+ if (isCI) {
78
+ console.log('🔧 Running in CI mode (auto-clean enabled)');
79
+ }
80
+
81
+ // Check if the script exists
82
+ if (!fs.existsSync(checkAllureScript)) {
83
+ console.error(`❌ Error: check-allure-results script not found at ${checkAllureScript}`);
84
+ console.error('Falling back to direct command execution...\n');
85
+
86
+ // Fallback: run command directly without Allure checking
87
+ const parts = command.split(' ');
88
+ const cmd = parts[0];
89
+ const cmdArgs = parts.slice(1);
90
+
91
+ const child = spawn(cmd, cmdArgs, {
92
+ stdio: 'inherit',
93
+ env: process.env,
94
+ });
95
+
96
+ child.on('close', (code) => {
97
+ process.exit(code);
98
+ });
99
+
100
+ child.on('error', (error) => {
101
+ console.error('❌ Failed to run test command:', error.message);
102
+ process.exit(1);
103
+ });
104
+ } else {
105
+ // Run the check-allure-results script with the test command
106
+ const child = spawn('node', [checkAllureScript, command], {
107
+ stdio: 'inherit',
108
+ env: process.env,
109
+ });
110
+
111
+ child.on('close', (code) => {
112
+ process.exit(code);
113
+ });
114
+
115
+ child.on('error', (error) => {
116
+ console.error('❌ Failed to run test command:', error.message);
117
+ process.exit(1);
118
+ });
119
+ }
@@ -0,0 +1,4 @@
1
+ export { createVitestConfig, mergeConfig, type SamaroVitestOptions } from './vitest.config.js';
2
+ export { createPlaywrightConfig, type SamaroPlaywrightOptions } from './playwright.config.js';
3
+ export { createComponentConfig, type SamaroComponentOptions } from './playwright.component.config.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createComponentConfig = exports.createPlaywrightConfig = exports.mergeConfig = exports.createVitestConfig = void 0;
4
+ var vitest_config_js_1 = require("./vitest.config.js");
5
+ Object.defineProperty(exports, "createVitestConfig", { enumerable: true, get: function () { return vitest_config_js_1.createVitestConfig; } });
6
+ Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return vitest_config_js_1.mergeConfig; } });
7
+ var playwright_config_js_1 = require("./playwright.config.js");
8
+ Object.defineProperty(exports, "createPlaywrightConfig", { enumerable: true, get: function () { return playwright_config_js_1.createPlaywrightConfig; } });
9
+ var playwright_component_config_js_1 = require("./playwright.component.config.js");
10
+ Object.defineProperty(exports, "createComponentConfig", { enumerable: true, get: function () { return playwright_component_config_js_1.createComponentConfig; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../config/index.ts"],"names":[],"mappings":";;;AAAA,uDAA+F;AAAtF,sHAAA,kBAAkB,OAAA;AAAE,+GAAA,WAAW,OAAA;AACxC,+DAA8F;AAArF,8HAAA,sBAAsB,OAAA;AAC/B,mFAAsG;AAA7F,uIAAA,qBAAqB,OAAA"}
@@ -0,0 +1,12 @@
1
+ import type { PlaywrightTestConfig } from '@playwright/test';
2
+ export interface SamaroComponentOptions {
3
+ baseURL?: string;
4
+ testDir?: string;
5
+ resultsDir?: string;
6
+ webServerCommand?: string;
7
+ webServerPort?: number;
8
+ }
9
+ export declare function createComponentConfig(options?: SamaroComponentOptions): PlaywrightTestConfig;
10
+ declare const _default: PlaywrightTestConfig;
11
+ export default _default;
12
+ //# sourceMappingURL=playwright.component.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.component.config.d.ts","sourceRoot":"","sources":["../../../config/playwright.component.config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,oBAAoB,CA8ChG;;AAED,wBAAuC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createComponentConfig = createComponentConfig;
4
+ const test_1 = require("@playwright/test");
5
+ function createComponentConfig(options = {}) {
6
+ const { baseURL = 'http://localhost:4200', testDir = './ct-tests', resultsDir = 'allure-ct-results', webServerCommand = 'npm run start', webServerPort = 4200, } = options;
7
+ return (0, test_1.defineConfig)({
8
+ testDir,
9
+ fullyParallel: true,
10
+ forbidOnly: !!process.env.CI,
11
+ retries: process.env.CI ? 2 : 0,
12
+ workers: process.env.CI ? 1 : undefined,
13
+ reporter: [
14
+ ['allure-playwright', {
15
+ resultsDir,
16
+ detail: true,
17
+ suiteTitle: true,
18
+ }],
19
+ ['html', { outputFolder: 'playwright-component-report' }],
20
+ ['list'],
21
+ ],
22
+ use: {
23
+ baseURL,
24
+ trace: 'on-first-retry',
25
+ screenshot: 'only-on-failure',
26
+ },
27
+ projects: [
28
+ {
29
+ name: 'chromium',
30
+ use: { ...test_1.devices['Desktop Chrome'] },
31
+ },
32
+ ],
33
+ webServer: {
34
+ command: webServerCommand,
35
+ url: `http://localhost:${webServerPort}`,
36
+ reuseExistingServer: !process.env.CI,
37
+ timeout: 120_000,
38
+ },
39
+ });
40
+ }
41
+ exports.default = createComponentConfig();
42
+ //# sourceMappingURL=playwright.component.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.component.config.js","sourceRoot":"","sources":["../../../config/playwright.component.config.ts"],"names":[],"mappings":";;AAWA,sDA8CC;AAzDD,2CAAyD;AAWzD,SAAgB,qBAAqB,CAAC,UAAkC,EAAE;IACxE,MAAM,EACJ,OAAO,GAAG,uBAAuB,EACjC,OAAO,GAAG,YAAY,EACtB,UAAU,GAAG,mBAAmB,EAChC,gBAAgB,GAAG,eAAe,EAClC,aAAa,GAAG,IAAI,GACrB,GAAG,OAAO,CAAC;IAEZ,OAAO,IAAA,mBAAY,EAAC;QAClB,OAAO;QACP,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAEvC,QAAQ,EAAE;YACR,CAAC,mBAAmB,EAAE;oBACpB,UAAU;oBACV,MAAM,EAAE,IAAI;oBACZ,UAAU,EAAE,IAAI;iBACjB,CAAC;YACF,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;YACzD,CAAC,MAAM,CAAC;SACT;QAED,GAAG,EAAE;YACH,OAAO;YACP,KAAK,EAAE,gBAAgB;YACvB,UAAU,EAAE,iBAAiB;SAC9B;QAED,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,UAAU;gBAChB,GAAG,EAAE,EAAE,GAAG,cAAO,CAAC,gBAAgB,CAAC,EAAE;aACtC;SACF;QAED,SAAS,EAAE;YACT,OAAO,EAAE,gBAAgB;YACzB,GAAG,EAAE,oBAAoB,aAAa,EAAE;YACxC,mBAAmB,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACpC,OAAO,EAAE,OAAO;SACjB;KACF,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PlaywrightTestConfig } from '@playwright/test';
2
+ export interface SamaroPlaywrightOptions {
3
+ baseURL?: string;
4
+ testDir?: string;
5
+ resultsDir?: string;
6
+ webServerCommand?: string;
7
+ webServerPort?: number;
8
+ webServerTimeout?: number;
9
+ timeout?: number;
10
+ }
11
+ export declare function createPlaywrightConfig(options?: SamaroPlaywrightOptions): PlaywrightTestConfig;
12
+ declare const _default: PlaywrightTestConfig<{}, {}>;
13
+ export default _default;
14
+ //# sourceMappingURL=playwright.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../config/playwright.config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,oBAAoB,CA4DlG;;AAED,wBAAsD"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPlaywrightConfig = createPlaywrightConfig;
4
+ const test_1 = require("@playwright/test");
5
+ function createPlaywrightConfig(options = {}) {
6
+ const { baseURL = 'http://localhost:4200', testDir = './e2e', resultsDir = 'allure-e2e-results', webServerCommand = 'npm run start', webServerPort = 4200, webServerTimeout = 120_000, timeout = 15_000, } = options;
7
+ return {
8
+ testDir,
9
+ fullyParallel: false,
10
+ forbidOnly: !!process.env.CI,
11
+ retries: process.env.CI ? 2 : 1,
12
+ workers: 1,
13
+ timeout,
14
+ reporter: [
15
+ ['allure-playwright', {
16
+ resultsDir,
17
+ detail: true,
18
+ suiteTitle: true,
19
+ environmentInfo: {
20
+ framework: 'playwright',
21
+ os_platform: process.platform,
22
+ node_version: process.version,
23
+ },
24
+ }],
25
+ ['html', { outputFolder: 'playwright-report' }],
26
+ ['list'],
27
+ ],
28
+ use: {
29
+ baseURL,
30
+ trace: 'on-first-retry',
31
+ screenshot: 'only-on-failure',
32
+ actionTimeout: 5_000,
33
+ navigationTimeout: 10_000,
34
+ },
35
+ expect: {
36
+ timeout: 5_000,
37
+ },
38
+ projects: [
39
+ {
40
+ name: 'chromium',
41
+ use: { ...test_1.devices['Desktop Chrome'] },
42
+ },
43
+ ],
44
+ webServer: {
45
+ command: webServerCommand,
46
+ url: `http://localhost:${webServerPort}`,
47
+ reuseExistingServer: !process.env.CI,
48
+ timeout: webServerTimeout,
49
+ },
50
+ };
51
+ }
52
+ exports.default = (0, test_1.defineConfig)(createPlaywrightConfig());
53
+ //# sourceMappingURL=playwright.config.js.map