@hyperfixi/testing-framework 2.0.0

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 (37) hide show
  1. package/dist/assertions-BImuwZsB.d.mts +458 -0
  2. package/dist/assertions-BImuwZsB.d.ts +458 -0
  3. package/dist/assertions.d.mts +1 -0
  4. package/dist/assertions.d.ts +1 -0
  5. package/dist/assertions.js +625 -0
  6. package/dist/assertions.js.map +1 -0
  7. package/dist/assertions.mjs +621 -0
  8. package/dist/assertions.mjs.map +1 -0
  9. package/dist/index.d.mts +246 -0
  10. package/dist/index.d.ts +246 -0
  11. package/dist/index.js +1465 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index.mjs +1435 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/package.json +121 -0
  16. package/src/assertions.test.ts +490 -0
  17. package/src/assertions.ts +779 -0
  18. package/src/index.test.ts +490 -0
  19. package/src/index.ts +601 -0
  20. package/src/jsdom.d.ts +7 -0
  21. package/src/multilingual/README.md +295 -0
  22. package/src/multilingual/bundle-builder.ts +345 -0
  23. package/src/multilingual/cli.ts +224 -0
  24. package/src/multilingual/index.ts +68 -0
  25. package/src/multilingual/orchestrator.ts +275 -0
  26. package/src/multilingual/pattern-loader.ts +176 -0
  27. package/src/multilingual/reporters/console-reporter.ts +294 -0
  28. package/src/multilingual/reporters/json-reporter.ts +99 -0
  29. package/src/multilingual/reporters/regression-reporter.ts +263 -0
  30. package/src/multilingual/tools/analyze-failures.ts +326 -0
  31. package/src/multilingual/types.ts +268 -0
  32. package/src/multilingual/validators/parse-diagnostics.ts +337 -0
  33. package/src/multilingual/validators/parse-validator.ts +193 -0
  34. package/src/multilingual/validators/size-validator.ts +187 -0
  35. package/src/runner.test.ts +813 -0
  36. package/src/runner.ts +639 -0
  37. package/src/types.ts +505 -0
@@ -0,0 +1,458 @@
1
+ /**
2
+ * Types for Testing Framework
3
+ */
4
+ /**
5
+ * Test environment types
6
+ */
7
+ type TestEnvironment = 'jsdom' | 'browser' | 'node' | 'playwright' | 'puppeteer';
8
+ /**
9
+ * Test status
10
+ */
11
+ type TestStatus = 'pending' | 'running' | 'passed' | 'failed' | 'skipped';
12
+ /**
13
+ * Browser type for testing
14
+ */
15
+ type BrowserType = 'chromium' | 'firefox' | 'webkit' | 'chrome' | 'edge';
16
+ /**
17
+ * Test configuration
18
+ */
19
+ interface TestConfig {
20
+ environment: TestEnvironment;
21
+ browser?: BrowserType;
22
+ timeout: number;
23
+ retries: number;
24
+ parallel: boolean;
25
+ maxWorkers: number;
26
+ headless: boolean;
27
+ viewport: {
28
+ width: number;
29
+ height: number;
30
+ };
31
+ baseURL?: string;
32
+ setupFiles: string[];
33
+ teardownFiles: string[];
34
+ reporters: TestReporter[];
35
+ coverage: {
36
+ enabled: boolean;
37
+ threshold: number;
38
+ include: string[];
39
+ exclude: string[];
40
+ };
41
+ fixtures: Record<string, any>;
42
+ }
43
+ /**
44
+ * Test suite definition
45
+ */
46
+ interface TestSuite {
47
+ name: string;
48
+ description?: string;
49
+ setup?: () => Promise<void> | void;
50
+ teardown?: () => Promise<void> | void;
51
+ beforeEach?: () => Promise<void> | void;
52
+ afterEach?: () => Promise<void> | void;
53
+ tests: TestCase[];
54
+ suites: TestSuite[];
55
+ timeout?: number;
56
+ retries?: number;
57
+ skip?: boolean;
58
+ only?: boolean;
59
+ }
60
+ /**
61
+ * Test case definition
62
+ */
63
+ interface TestCase {
64
+ name: string;
65
+ description?: string;
66
+ fn: TestFunction;
67
+ timeout?: number;
68
+ retries?: number;
69
+ skip?: boolean;
70
+ only?: boolean;
71
+ tags: string[];
72
+ fixtures: Record<string, any>;
73
+ }
74
+ /**
75
+ * Test function signature
76
+ */
77
+ type TestFunction = (context: TestContext) => Promise<void> | void;
78
+ /**
79
+ * Test context
80
+ */
81
+ interface TestContext {
82
+ suite: string;
83
+ test: string;
84
+ environment: TestEnvironment;
85
+ page?: any;
86
+ browser?: any;
87
+ document?: Document;
88
+ window?: Window;
89
+ hyperfixi?: any;
90
+ fixtures: Record<string, any>;
91
+ expect: ExpectAPI;
92
+ assert: AssertAPI;
93
+ skip: () => void;
94
+ fail: (message: string) => never;
95
+ timeout: (ms: number) => void;
96
+ }
97
+ /**
98
+ * Test result
99
+ */
100
+ interface TestResult {
101
+ suite: string;
102
+ test: string;
103
+ status: TestStatus;
104
+ duration: number;
105
+ error?: TestError | undefined;
106
+ logs: TestLog[];
107
+ screenshots: string[];
108
+ coverage?: CoverageData | undefined;
109
+ }
110
+ /**
111
+ * Test error
112
+ */
113
+ interface TestError {
114
+ name: string;
115
+ message: string;
116
+ stack?: string | undefined;
117
+ code?: string | undefined;
118
+ expected?: any | undefined;
119
+ actual?: any | undefined;
120
+ diff?: string | undefined;
121
+ }
122
+ /**
123
+ * Test log entry
124
+ */
125
+ interface TestLog {
126
+ level: 'info' | 'warn' | 'error' | 'debug';
127
+ message: string;
128
+ timestamp: number;
129
+ source?: string;
130
+ }
131
+ /**
132
+ * Coverage data
133
+ */
134
+ interface CoverageData {
135
+ lines: {
136
+ total: number;
137
+ covered: number;
138
+ percentage: number;
139
+ };
140
+ functions: {
141
+ total: number;
142
+ covered: number;
143
+ percentage: number;
144
+ };
145
+ branches: {
146
+ total: number;
147
+ covered: number;
148
+ percentage: number;
149
+ };
150
+ statements: {
151
+ total: number;
152
+ covered: number;
153
+ percentage: number;
154
+ };
155
+ }
156
+ /**
157
+ * Test reporter interface
158
+ */
159
+ interface TestReporter {
160
+ name: string;
161
+ onStart: (suites: TestSuite[]) => void;
162
+ onSuiteStart: (suite: TestSuite) => void;
163
+ onSuiteEnd: (suite: TestSuite, results: TestResult[]) => void;
164
+ onTestStart: (test: TestCase) => void;
165
+ onTestEnd: (test: TestCase, result: TestResult) => void;
166
+ onEnd: (results: TestResult[]) => void;
167
+ }
168
+ /**
169
+ * Expect API for assertions
170
+ */
171
+ interface ExpectAPI {
172
+ (actual: any): ExpectMatcher;
173
+ }
174
+ /**
175
+ * Expect matcher interface
176
+ */
177
+ interface ExpectMatcher {
178
+ toBe(expected: any): void;
179
+ toEqual(expected: any): void;
180
+ toStrictEqual(expected: any): void;
181
+ toBeTruthy(): void;
182
+ toBeFalsy(): void;
183
+ toBeNull(): void;
184
+ toBeUndefined(): void;
185
+ toBeDefined(): void;
186
+ toBeNaN(): void;
187
+ toBeInstanceOf(constructor: any): void;
188
+ toBeCloseTo(expected: number, precision?: number): void;
189
+ toMatch(expected: string | RegExp): void;
190
+ toContain(expected: any): void;
191
+ toHaveLength(expected: number): void;
192
+ toContainEqual(expected: any): void;
193
+ toHaveProperty(path: string, value?: any): void;
194
+ toMatchObject(expected: object): void;
195
+ resolves: ExpectMatcher;
196
+ rejects: ExpectMatcher;
197
+ toBeInTheDocument(): void;
198
+ toBeVisible(): void;
199
+ toBeDisabled(): void;
200
+ toBeEnabled(): void;
201
+ toBeChecked(): void;
202
+ toHaveClass(className: string): void;
203
+ toHaveAttribute(name: string, value?: string): void;
204
+ toHaveTextContent(text: string | RegExp): void;
205
+ toHaveValue(value: any): void;
206
+ toHaveCompiledScript(): void;
207
+ toHaveExecutedScript(): void;
208
+ toHaveTriggeredEvent(eventType: string): void;
209
+ toHaveUpdatedElement(): void;
210
+ not: ExpectMatcher;
211
+ }
212
+ /**
213
+ * Assert API
214
+ */
215
+ interface AssertAPI {
216
+ ok(value: any, message?: string): void;
217
+ equal(actual: any, expected: any, message?: string): void;
218
+ strictEqual(actual: any, expected: any, message?: string): void;
219
+ notEqual(actual: any, expected: any, message?: string): void;
220
+ notStrictEqual(actual: any, expected: any, message?: string): void;
221
+ throws(fn: () => void, error?: any, message?: string): void;
222
+ doesNotThrow(fn: () => void, message?: string): void;
223
+ ifError(value: any): void;
224
+ rejects(promise: Promise<any>, error?: any, message?: string): Promise<void>;
225
+ doesNotReject(promise: Promise<any>, message?: string): Promise<void>;
226
+ elementExists(selector: string, message?: string): void;
227
+ elementVisible(selector: string, message?: string): void;
228
+ elementHasClass(selector: string, className: string, message?: string): void;
229
+ elementHasText(selector: string, text: string, message?: string): void;
230
+ scriptCompiled(script: string, message?: string): void;
231
+ scriptExecuted(script: string, message?: string): void;
232
+ eventTriggered(eventType: string, message?: string): void;
233
+ }
234
+ /**
235
+ * Page object model interface
236
+ */
237
+ interface PageObject {
238
+ name: string;
239
+ url?: string;
240
+ selectors: Record<string, string>;
241
+ actions: Record<string, (...args: any[]) => Promise<any>>;
242
+ assertions: Record<string, (...args: any[]) => Promise<void>>;
243
+ }
244
+ /**
245
+ * Test data provider interface
246
+ */
247
+ interface TestDataProvider {
248
+ name: string;
249
+ provide: () => Promise<any[]> | any[];
250
+ }
251
+ /**
252
+ * Test fixture interface
253
+ */
254
+ interface TestFixture {
255
+ name: string;
256
+ setup: (context: TestContext) => Promise<any> | any;
257
+ teardown?: (fixture: any, context: TestContext) => Promise<void> | void;
258
+ }
259
+ /**
260
+ * Browser testing options
261
+ */
262
+ interface BrowserTestOptions {
263
+ browser: BrowserType;
264
+ headless: boolean;
265
+ viewport: {
266
+ width: number;
267
+ height: number;
268
+ };
269
+ deviceScaleFactor?: number;
270
+ userAgent?: string;
271
+ locale?: string;
272
+ timezone?: string;
273
+ permissions?: string[];
274
+ geolocation?: {
275
+ latitude: number;
276
+ longitude: number;
277
+ };
278
+ screenshot?: {
279
+ mode: 'off' | 'on' | 'only-on-failure';
280
+ fullPage: boolean;
281
+ };
282
+ video?: {
283
+ enabled: boolean;
284
+ dir: string;
285
+ };
286
+ }
287
+ /**
288
+ * E2E test step
289
+ */
290
+ interface E2EStep {
291
+ name: string;
292
+ action: E2EAction;
293
+ selector?: string;
294
+ value?: any;
295
+ options?: Record<string, any>;
296
+ screenshot?: boolean;
297
+ wait?: number | string;
298
+ }
299
+ /**
300
+ * E2E action types
301
+ */
302
+ type E2EAction = 'goto' | 'click' | 'type' | 'select' | 'check' | 'uncheck' | 'hover' | 'focus' | 'blur' | 'scroll' | 'wait' | 'screenshot' | 'evaluate' | 'assert';
303
+ /**
304
+ * Visual regression test configuration
305
+ */
306
+ interface VisualTestConfig {
307
+ threshold: number;
308
+ includeAA: boolean;
309
+ animations: 'disabled' | 'allow';
310
+ clip?: {
311
+ x: number;
312
+ y: number;
313
+ width: number;
314
+ height: number;
315
+ };
316
+ fullPage: boolean;
317
+ mask?: string[];
318
+ }
319
+ /**
320
+ * Performance test metrics
321
+ */
322
+ interface PerformanceMetrics {
323
+ loadTime: number;
324
+ domContentLoaded: number;
325
+ firstPaint: number;
326
+ firstContentfulPaint: number;
327
+ largestContentfulPaint: number;
328
+ cumulativeLayoutShift: number;
329
+ firstInputDelay: number;
330
+ memoryUsage: {
331
+ usedJSHeapSize: number;
332
+ totalJSHeapSize: number;
333
+ jsHeapSizeLimit: number;
334
+ };
335
+ }
336
+ /**
337
+ * Accessibility test result
338
+ */
339
+ interface AccessibilityResult {
340
+ violations: AccessibilityViolation[];
341
+ passes: AccessibilityPass[];
342
+ incomplete: AccessibilityIncomplete[];
343
+ }
344
+ /**
345
+ * Accessibility violation
346
+ */
347
+ interface AccessibilityViolation {
348
+ id: string;
349
+ impact: 'minor' | 'moderate' | 'serious' | 'critical';
350
+ description: string;
351
+ help: string;
352
+ helpUrl: string;
353
+ nodes: AccessibilityNode[];
354
+ }
355
+ /**
356
+ * Accessibility pass
357
+ */
358
+ interface AccessibilityPass {
359
+ id: string;
360
+ description: string;
361
+ nodes: AccessibilityNode[];
362
+ }
363
+ /**
364
+ * Accessibility incomplete
365
+ */
366
+ interface AccessibilityIncomplete {
367
+ id: string;
368
+ description: string;
369
+ nodes: AccessibilityNode[];
370
+ }
371
+ /**
372
+ * Accessibility node
373
+ */
374
+ interface AccessibilityNode {
375
+ target: string[];
376
+ html: string;
377
+ impact?: 'minor' | 'moderate' | 'serious' | 'critical';
378
+ any: AccessibilityCheckResult[];
379
+ all: AccessibilityCheckResult[];
380
+ none: AccessibilityCheckResult[];
381
+ }
382
+ /**
383
+ * Accessibility check result
384
+ */
385
+ interface AccessibilityCheckResult {
386
+ id: string;
387
+ data: any;
388
+ relatedNodes: any[];
389
+ impact: string;
390
+ message: string;
391
+ }
392
+ /**
393
+ * Test runner interface
394
+ */
395
+ interface TestRunner {
396
+ run: (suites: TestSuite[], config: TestConfig) => Promise<TestResult[]>;
397
+ runSuite: (suite: TestSuite, config: TestConfig) => Promise<TestResult[]>;
398
+ runTest: (test: TestCase, context: TestContext) => Promise<TestResult>;
399
+ }
400
+ /**
401
+ * Test discovery options
402
+ */
403
+ interface TestDiscoveryOptions {
404
+ patterns: string[];
405
+ ignore: string[];
406
+ recursive: boolean;
407
+ extensions: string[];
408
+ }
409
+ /**
410
+ * Mock function interface
411
+ */
412
+ interface MockFunction {
413
+ (...args: any[]): any;
414
+ mockReturnValue: (value: any) => MockFunction;
415
+ mockReturnValueOnce: (value: any) => MockFunction;
416
+ mockResolvedValue: (value: any) => MockFunction;
417
+ mockRejectedValue: (error: any) => MockFunction;
418
+ mockImplementation: (fn: (...args: any[]) => any) => MockFunction;
419
+ mockClear: () => MockFunction;
420
+ mockReset: () => MockFunction;
421
+ mockRestore: () => MockFunction;
422
+ calls: any[][];
423
+ results: Array<{
424
+ type: 'return' | 'throw';
425
+ value: any;
426
+ }>;
427
+ }
428
+ /**
429
+ * Spy function interface
430
+ */
431
+ interface SpyFunction extends MockFunction {
432
+ original: Function;
433
+ }
434
+
435
+ /**
436
+ * Assertion Library
437
+ * Comprehensive assertion and expectation framework for HyperFixi testing
438
+ */
439
+
440
+ /**
441
+ * Assertion error class
442
+ */
443
+ declare class AssertionError extends Error {
444
+ expected?: any | undefined;
445
+ actual?: any | undefined;
446
+ operator?: string | undefined;
447
+ constructor(message: string, expected?: any | undefined, actual?: any | undefined, operator?: string | undefined);
448
+ }
449
+ /**
450
+ * Create expect API
451
+ */
452
+ declare function createExpectAPI(): ExpectAPI;
453
+ /**
454
+ * Create assert API
455
+ */
456
+ declare function createAssertAPI(): AssertAPI;
457
+
458
+ export { AssertionError as A, type BrowserType as B, type CoverageData as C, type AccessibilityNode as D, type ExpectAPI as E, type AccessibilityCheckResult as F, type MockFunction as M, type PerformanceMetrics as P, type SpyFunction as S, type TestRunner as T, type VisualTestConfig as V, type TestSuite as a, type TestConfig as b, type TestResult as c, type TestCase as d, type TestContext as e, type TestFunction as f, type PageObject as g, type TestEnvironment as h, createExpectAPI as i, createAssertAPI as j, type TestStatus as k, type TestError as l, type TestLog as m, type BrowserTestOptions as n, type ExpectMatcher as o, type AssertAPI as p, type TestReporter as q, type TestDataProvider as r, type TestFixture as s, type TestDiscoveryOptions as t, type E2EStep as u, type E2EAction as v, type AccessibilityResult as w, type AccessibilityViolation as x, type AccessibilityPass as y, type AccessibilityIncomplete as z };