@react-native-harness/cli 1.0.0-alpha.20 โ†’ 1.0.0-alpha.21

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 (94) hide show
  1. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  2. package/package.json +3 -3
  3. package/dist/bundlers/metro.d.ts +0 -5
  4. package/dist/bundlers/metro.d.ts.map +0 -1
  5. package/dist/bundlers/metro.js +0 -71
  6. package/dist/bundlers/webpack.d.ts +0 -2
  7. package/dist/bundlers/webpack.d.ts.map +0 -1
  8. package/dist/bundlers/webpack.js +0 -49
  9. package/dist/commands/test.d.ts +0 -3
  10. package/dist/commands/test.d.ts.map +0 -1
  11. package/dist/commands/test.js +0 -140
  12. package/dist/discovery/index.d.ts +0 -3
  13. package/dist/discovery/index.d.ts.map +0 -1
  14. package/dist/discovery/index.js +0 -1
  15. package/dist/discovery/testDiscovery.d.ts +0 -11
  16. package/dist/discovery/testDiscovery.d.ts.map +0 -1
  17. package/dist/discovery/testDiscovery.js +0 -29
  18. package/dist/errors/appNotInstalledError.d.ts +0 -7
  19. package/dist/errors/appNotInstalledError.d.ts.map +0 -1
  20. package/dist/errors/appNotInstalledError.js +0 -12
  21. package/dist/errors/bridgeTimeoutError.d.ts +0 -7
  22. package/dist/errors/bridgeTimeoutError.d.ts.map +0 -1
  23. package/dist/errors/bridgeTimeoutError.js +0 -12
  24. package/dist/errors/errorHandler.d.ts +0 -2
  25. package/dist/errors/errorHandler.d.ts.map +0 -1
  26. package/dist/errors/errorHandler.js +0 -152
  27. package/dist/errors/errors.d.ts +0 -45
  28. package/dist/errors/errors.d.ts.map +0 -1
  29. package/dist/errors/errors.js +0 -89
  30. package/dist/jest.d.ts +0 -2
  31. package/dist/jest.d.ts.map +0 -1
  32. package/dist/jest.js +0 -7
  33. package/dist/platforms/android/build.d.ts +0 -5
  34. package/dist/platforms/android/build.d.ts.map +0 -1
  35. package/dist/platforms/android/build.js +0 -29
  36. package/dist/platforms/android/device.d.ts +0 -5
  37. package/dist/platforms/android/device.d.ts.map +0 -1
  38. package/dist/platforms/android/device.js +0 -36
  39. package/dist/platforms/android/emulator.d.ts +0 -10
  40. package/dist/platforms/android/emulator.d.ts.map +0 -1
  41. package/dist/platforms/android/emulator.js +0 -116
  42. package/dist/platforms/android/index.d.ts +0 -4
  43. package/dist/platforms/android/index.d.ts.map +0 -1
  44. package/dist/platforms/android/index.js +0 -56
  45. package/dist/platforms/ios/build.d.ts +0 -7
  46. package/dist/platforms/ios/build.d.ts.map +0 -1
  47. package/dist/platforms/ios/build.js +0 -48
  48. package/dist/platforms/ios/device.d.ts +0 -11
  49. package/dist/platforms/ios/device.d.ts.map +0 -1
  50. package/dist/platforms/ios/device.js +0 -51
  51. package/dist/platforms/ios/index.d.ts +0 -4
  52. package/dist/platforms/ios/index.d.ts.map +0 -1
  53. package/dist/platforms/ios/index.js +0 -43
  54. package/dist/platforms/ios/simulator.d.ts +0 -11
  55. package/dist/platforms/ios/simulator.d.ts.map +0 -1
  56. package/dist/platforms/ios/simulator.js +0 -129
  57. package/dist/platforms/platform-adapter.d.ts +0 -10
  58. package/dist/platforms/platform-adapter.d.ts.map +0 -1
  59. package/dist/platforms/platform-adapter.js +0 -1
  60. package/dist/platforms/platform-registry.d.ts +0 -3
  61. package/dist/platforms/platform-registry.d.ts.map +0 -1
  62. package/dist/platforms/platform-registry.js +0 -21
  63. package/dist/platforms/vega/build.d.ts +0 -23
  64. package/dist/platforms/vega/build.d.ts.map +0 -1
  65. package/dist/platforms/vega/build.js +0 -55
  66. package/dist/platforms/vega/device.d.ts +0 -57
  67. package/dist/platforms/vega/device.d.ts.map +0 -1
  68. package/dist/platforms/vega/device.js +0 -206
  69. package/dist/platforms/vega/index.d.ts +0 -4
  70. package/dist/platforms/vega/index.d.ts.map +0 -1
  71. package/dist/platforms/vega/index.js +0 -75
  72. package/dist/platforms/web/index.d.ts +0 -4
  73. package/dist/platforms/web/index.d.ts.map +0 -1
  74. package/dist/platforms/web/index.js +0 -9
  75. package/dist/process.d.ts +0 -3
  76. package/dist/process.d.ts.map +0 -1
  77. package/dist/process.js +0 -28
  78. package/dist/reporters/default-reporter.d.ts +0 -3
  79. package/dist/reporters/default-reporter.d.ts.map +0 -1
  80. package/dist/reporters/default-reporter.js +0 -116
  81. package/dist/reporters/junit-reporter.d.ts +0 -3
  82. package/dist/reporters/junit-reporter.d.ts.map +0 -1
  83. package/dist/reporters/junit-reporter.js +0 -119
  84. package/dist/reporters/live-reporter.d.ts +0 -20
  85. package/dist/reporters/live-reporter.d.ts.map +0 -1
  86. package/dist/reporters/live-reporter.js +0 -176
  87. package/dist/src/reporters/default-reporter.js +0 -135
  88. package/dist/test-reporter-demo.js +0 -95
  89. package/dist/utils/status-formatter.d.ts +0 -27
  90. package/dist/utils/status-formatter.d.ts.map +0 -1
  91. package/dist/utils/status-formatter.js +0 -54
  92. package/dist/utils.d.ts +0 -6
  93. package/dist/utils.d.ts.map +0 -1
  94. package/dist/utils.js +0 -26
@@ -1,119 +0,0 @@
1
- import { writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- export const junitReporter = {
4
- report: async (results) => {
5
- const xml = generateJUnitXML(results);
6
- // Write to junit.xml file
7
- const outputPath = join(process.cwd(), 'junit.xml');
8
- writeFileSync(outputPath, xml, 'utf8');
9
- console.log(`๐Ÿ“„ JUnit report written to: ${outputPath}`);
10
- },
11
- };
12
- const generateJUnitXML = (results) => {
13
- const { totalTests, totalFailures, totalSkipped, totalTime } = calculateTotals(results);
14
- let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
15
- xml += `<testsuites tests="${totalTests}" failures="${totalFailures}" skipped="${totalSkipped}" time="${totalTime / 1000}">\n`;
16
- for (const suite of results) {
17
- xml += generateTestSuiteXML(suite, ' ');
18
- }
19
- xml += '</testsuites>\n';
20
- return xml;
21
- };
22
- const generateTestSuiteXML = (suite, indent) => {
23
- const { tests, failures, skipped, time } = getSuiteStats(suite);
24
- let xml = `${indent}<testsuite name="${escapeXML(suite.name)}" tests="${tests}" failures="${failures}" skipped="${skipped}" time="${time / 1000}"`;
25
- if (suite.error) {
26
- xml += ` errors="1"`;
27
- }
28
- xml += '>\n';
29
- // Add suite-level error if present
30
- if (suite.error) {
31
- xml += `${indent} <error message="${escapeXML(suite.error.message || 'Suite failed')}"`;
32
- if (suite.error.name) {
33
- xml += ` type="${escapeXML(suite.error.name)}"`;
34
- }
35
- xml += '>';
36
- if (suite.error.stack) {
37
- xml += escapeXML(suite.error.stack);
38
- }
39
- xml += '</error>\n';
40
- }
41
- // Add individual test cases
42
- for (const test of suite.tests) {
43
- xml += generateTestCaseXML(test, indent + ' ');
44
- }
45
- // Add nested suites
46
- for (const nestedSuite of suite.suites) {
47
- xml += generateTestSuiteXML(nestedSuite, indent + ' ');
48
- }
49
- xml += `${indent}</testsuite>\n`;
50
- return xml;
51
- };
52
- const generateTestCaseXML = (test, indent) => {
53
- const time = (test.duration || 0) / 1000;
54
- let xml = `${indent}<testcase name="${escapeXML(test.name)}" time="${time}"`;
55
- if (test.status === 'passed') {
56
- xml += '/>\n';
57
- }
58
- else {
59
- xml += '>\n';
60
- switch (test.status) {
61
- case 'failed':
62
- xml += `${indent} <failure message="${escapeXML(test.error?.message || 'Test failed')}"`;
63
- if (test.error?.name) {
64
- xml += ` type="${escapeXML(test.error.name)}"`;
65
- }
66
- xml += '>';
67
- if (test.error?.stack) {
68
- xml += escapeXML(test.error.stack);
69
- }
70
- xml += '</failure>\n';
71
- break;
72
- case 'skipped':
73
- xml += `${indent} <skipped/>\n`;
74
- break;
75
- case 'todo':
76
- xml += `${indent} <skipped message="TODO: Test not implemented"/>\n`;
77
- break;
78
- }
79
- xml += `${indent}</testcase>\n`;
80
- }
81
- return xml;
82
- };
83
- const calculateTotals = (results) => {
84
- let totalTests = 0;
85
- let totalFailures = 0;
86
- let totalSkipped = 0;
87
- let totalTime = 0;
88
- for (const suite of results) {
89
- const stats = getSuiteStats(suite);
90
- totalTests += stats.tests;
91
- totalFailures += stats.failures;
92
- totalSkipped += stats.skipped;
93
- totalTime += stats.time;
94
- }
95
- return { totalTests, totalFailures, totalSkipped, totalTime };
96
- };
97
- const getSuiteStats = (suite) => {
98
- let tests = suite.tests.length;
99
- let failures = suite.tests.filter((t) => t.status === 'failed').length;
100
- let skipped = suite.tests.filter((t) => t.status === 'skipped' || t.status === 'todo').length;
101
- let time = suite.duration || 0;
102
- // Add stats from nested suites
103
- for (const nestedSuite of suite.suites) {
104
- const nestedStats = getSuiteStats(nestedSuite);
105
- tests += nestedStats.tests;
106
- failures += nestedStats.failures;
107
- skipped += nestedStats.skipped;
108
- time += nestedStats.time;
109
- }
110
- return { tests, failures, skipped, time };
111
- };
112
- const escapeXML = (str) => {
113
- return str
114
- .replace(/&/g, '&amp;')
115
- .replace(/</g, '&lt;')
116
- .replace(/>/g, '&gt;')
117
- .replace(/"/g, '&quot;')
118
- .replace(/'/g, '&apos;');
119
- };
@@ -1,20 +0,0 @@
1
- import type { SuiteResult, LiveReportingEvent } from '@react-native-harness/bridge';
2
- import { Reporter } from '@react-native-harness/config';
3
- export declare class LiveReporter {
4
- private state;
5
- private progressSpinner;
6
- constructor();
7
- start(): void;
8
- handleLiveEvent(event: LiveReportingEvent): void;
9
- private getStatusSymbol;
10
- private updateProgress;
11
- private formatDuration;
12
- stop(message: string): void;
13
- countTests(suite: SuiteResult): number;
14
- setTotalTests(results: SuiteResult[]): void;
15
- }
16
- export declare const createLiveReporter: () => {
17
- reporter: Reporter;
18
- liveReporter: LiveReporter;
19
- };
20
- //# sourceMappingURL=live-reporter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-reporter.d.ts","sourceRoot":"","sources":["../../src/reporters/live-reporter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAEX,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAcxD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,eAAe,CAA6B;;IAiBpD,KAAK;IAKL,eAAe,CAAC,KAAK,EAAE,kBAAkB;IA4DzC,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,cAAc;IAMtB,IAAI,CAAC,OAAO,EAAE,MAAM;IAKpB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAQtC,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE;CAMrC;AAED,eAAO,MAAM,kBAAkB,QAAO;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;CA0C5B,CAAC"}
@@ -1,176 +0,0 @@
1
- import { color, spinner } from '@react-native-harness/tools';
2
- export class LiveReporter {
3
- state;
4
- progressSpinner;
5
- constructor() {
6
- this.state = {
7
- totalTests: 0,
8
- completedTests: 0,
9
- passedTests: 0,
10
- failedTests: 0,
11
- skippedTests: 0,
12
- todoTests: 0,
13
- currentTest: null,
14
- currentSuite: null,
15
- startTime: Date.now(),
16
- };
17
- this.progressSpinner = spinner();
18
- }
19
- start() {
20
- this.state.startTime = Date.now();
21
- this.progressSpinner.start('Initializing tests...');
22
- }
23
- handleLiveEvent(event) {
24
- switch (event.type) {
25
- case 'suite_started':
26
- this.state.currentSuite = event.suiteHierarchy.join(' > ');
27
- this.updateProgress(`Starting suite: ${this.state.currentSuite}`);
28
- break;
29
- case 'test_started':
30
- this.state.currentTest = `${event.suiteHierarchy.join(' > ')} > ${event.testName}`;
31
- this.updateProgress(`Running: ${event.testName}`);
32
- break;
33
- case 'test_completed':
34
- this.state.completedTests++;
35
- switch (event.result.status) {
36
- case 'passed':
37
- this.state.passedTests++;
38
- break;
39
- case 'failed':
40
- this.state.failedTests++;
41
- break;
42
- case 'skipped':
43
- this.state.skippedTests++;
44
- break;
45
- case 'todo':
46
- this.state.todoTests++;
47
- break;
48
- }
49
- const statusSymbol = this.getStatusSymbol(event.result.status);
50
- const duration = event.result.duration
51
- ? ` (${event.result.duration}ms)`
52
- : '';
53
- this.updateProgress(`${statusSymbol} ${event.testName}${duration}`, event.result.status === 'failed'
54
- ? event.result.error?.message
55
- : undefined);
56
- break;
57
- case 'suite_completed':
58
- const suiteStatusSymbol = this.getStatusSymbol(event.result.status);
59
- const suiteDuration = event.result.duration
60
- ? ` (${event.result.duration}ms)`
61
- : '';
62
- this.updateProgress(`${suiteStatusSymbol} Suite completed: ${event.suiteHierarchy.join(' > ')}${suiteDuration}`);
63
- break;
64
- }
65
- }
66
- getStatusSymbol(status) {
67
- switch (status) {
68
- case 'passed':
69
- return color.green('โœ“');
70
- case 'failed':
71
- return color.red('โœ—');
72
- case 'skipped':
73
- return color.yellow('-');
74
- case 'todo':
75
- return color.blue('โ—‹');
76
- default:
77
- return '?';
78
- }
79
- }
80
- updateProgress(message, error) {
81
- const elapsed = Date.now() - this.state.startTime;
82
- const elapsedFormatted = this.formatDuration(elapsed);
83
- const progress = this.state.totalTests > 0
84
- ? ` [${this.state.completedTests}/${this.state.totalTests}]`
85
- : ` [${this.state.completedTests} completed]`;
86
- const summary = [
87
- color.green(`${this.state.passedTests} passed`),
88
- ...(this.state.failedTests > 0
89
- ? [color.red(`${this.state.failedTests} failed`)]
90
- : []),
91
- ...(this.state.skippedTests > 0
92
- ? [color.yellow(`${this.state.skippedTests} skipped`)]
93
- : []),
94
- ...(this.state.todoTests > 0
95
- ? [color.blue(`${this.state.todoTests} todo`)]
96
- : []),
97
- ].join(', ');
98
- this.progressSpinner.message(`${message}${progress} | ${summary} | ${elapsedFormatted}${error ? `\n ${color.red('Error:')} ${error}` : ''}`);
99
- }
100
- formatDuration(ms) {
101
- if (ms < 1000)
102
- return `${ms}ms`;
103
- if (ms < 60000)
104
- return `${(ms / 1000).toFixed(1)}s`;
105
- return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
106
- }
107
- stop(message) {
108
- this.progressSpinner.stop(message);
109
- }
110
- // Count total tests in suite hierarchy
111
- countTests(suite) {
112
- let count = suite.tests.length;
113
- for (const childSuite of suite.suites) {
114
- count += this.countTests(childSuite);
115
- }
116
- return count;
117
- }
118
- setTotalTests(results) {
119
- this.state.totalTests = results.reduce((sum, suite) => sum + this.countTests(suite), 0);
120
- }
121
- }
122
- export const createLiveReporter = () => {
123
- const liveReporter = new LiveReporter();
124
- const reporter = {
125
- report: async (results) => {
126
- // Final summary is handled by the existing default reporter logic
127
- const totalPassed = results.reduce((sum, suite) => sum + getTestSummary(suite).passed, 0);
128
- const totalFailed = results.reduce((sum, suite) => sum + getTestSummary(suite).failed, 0);
129
- const totalSkipped = results.reduce((sum, suite) => sum + getTestSummary(suite).skipped, 0);
130
- const totalTodo = results.reduce((sum, suite) => sum + getTestSummary(suite).todo, 0);
131
- const totalDuration = results.reduce((sum, suite) => sum + (suite.duration || 0), 0);
132
- const summaryText = [
133
- color.green(`${totalPassed} passed`),
134
- color.red(`${totalFailed} failed`),
135
- color.yellow(`${totalSkipped} skipped`),
136
- color.blue(`${totalTodo} todo`),
137
- ].join(', ');
138
- liveReporter.stop(`Summary: ${summaryText} | Total time: ${formatDuration(totalDuration)}`);
139
- },
140
- };
141
- return { reporter, liveReporter };
142
- };
143
- const getTestSummary = (suite) => {
144
- let passed = 0, failed = 0, skipped = 0, todo = 0;
145
- // Count tests in current suite
146
- for (const test of suite.tests) {
147
- switch (test.status) {
148
- case 'passed':
149
- passed++;
150
- break;
151
- case 'failed':
152
- failed++;
153
- break;
154
- case 'skipped':
155
- skipped++;
156
- break;
157
- case 'todo':
158
- todo++;
159
- break;
160
- }
161
- }
162
- // Count tests in nested suites
163
- for (const childSuite of suite.suites) {
164
- const childSummary = getTestSummary(childSuite);
165
- passed += childSummary.passed;
166
- failed += childSummary.failed;
167
- skipped += childSummary.skipped;
168
- todo += childSummary.todo;
169
- }
170
- return { passed, failed, skipped, todo };
171
- };
172
- const formatDuration = (duration) => duration
173
- ? duration < 1000
174
- ? `${duration}ms`
175
- : `${(duration / 1000).toFixed(2)}s`
176
- : '0ms';
@@ -1,135 +0,0 @@
1
- import { color, logger } from '@react-native-harness/tools';
2
- export const defaultReporter = {
3
- report: async (results) => {
4
- logger.log('\n๐Ÿ“‹ Test Results');
5
- console.log(color.dim('โ”'.repeat(60)));
6
- for (const suite of results) {
7
- console.log(formatSuiteResult(suite));
8
- }
9
- console.log(color.dim('โ”'.repeat(60)));
10
- // Summary
11
- let totalPassed = 0, totalFailed = 0, totalSkipped = 0, totalTodo = 0;
12
- let totalDuration = 0;
13
- for (const suite of results) {
14
- const summary = getTestSummary(suite);
15
- totalPassed += summary.passed;
16
- totalFailed += summary.failed;
17
- totalSkipped += summary.skipped;
18
- totalTodo += summary.todo;
19
- totalDuration += suite.duration || 0;
20
- }
21
- // Create summary with modern styling
22
- const summaryParts = [];
23
- if (totalPassed > 0) {
24
- summaryParts.push(color.green(`${totalPassed} passed`));
25
- }
26
- if (totalFailed > 0) {
27
- summaryParts.push(color.red(`${totalFailed} failed`));
28
- }
29
- if (totalSkipped > 0) {
30
- summaryParts.push(color.yellow(`${totalSkipped} skipped`));
31
- }
32
- if (totalTodo > 0) {
33
- summaryParts.push(color.blue(`${totalTodo} todo`));
34
- }
35
- const summaryText = summaryParts.join(color.dim(' โ€ข '));
36
- const durationText = formatDuration(totalDuration);
37
- logger.info(`๐Ÿ“Š Summary: ${summaryText}${durationText}`);
38
- // Show appropriate final message
39
- if (totalFailed === 0 && totalPassed > 0) {
40
- logger.success('All tests passed! ๐ŸŽ‰');
41
- }
42
- else if (totalFailed > 0) {
43
- logger.error(`${totalFailed} test${totalFailed === 1 ? '' : 's'} failed`);
44
- }
45
- },
46
- };
47
- const formatDuration = (duration) => {
48
- if (!duration)
49
- return '';
50
- return color.dim(` (${duration}ms)`);
51
- };
52
- const getStatusIcon = (status) => {
53
- switch (status) {
54
- case 'passed':
55
- return color.green('โœ“');
56
- case 'failed':
57
- return color.red('โœ—');
58
- case 'skipped':
59
- return color.yellow('โ—‹');
60
- case 'todo':
61
- return color.blue('โ—');
62
- default:
63
- return '?';
64
- }
65
- };
66
- const formatTestResult = (test, indent = '') => {
67
- const icon = getStatusIcon(test.status);
68
- const name = test.status === 'failed' ? color.red(test.name) : test.name;
69
- const duration = formatDuration(test.duration);
70
- let result = `${indent}${icon} ${name}${duration}`;
71
- if (test.error) {
72
- const errorLines = test.error.message?.split('\n') || [];
73
- result +=
74
- '\n' +
75
- errorLines
76
- .map((line) => `${indent} ${color.red(line)}`)
77
- .join('\n');
78
- }
79
- return result;
80
- };
81
- const formatSuiteResult = (suite, indent = '') => {
82
- const icon = getStatusIcon(suite.status);
83
- const name = suite.status === 'failed'
84
- ? color.red(color.bold(suite.name))
85
- : color.bold(color.cyan(suite.name));
86
- const duration = formatDuration(suite.duration);
87
- let result = `${indent}${icon} ${name}${duration}`;
88
- if (suite.error) {
89
- const errorLines = suite.error.message.split('\n');
90
- result +=
91
- '\n' +
92
- errorLines
93
- .map((line) => `${indent} ${color.red(line)}`)
94
- .join('\n');
95
- }
96
- const childIndent = indent + ' ';
97
- // Format tests
98
- for (const test of suite.tests) {
99
- result += '\n' + formatTestResult(test, childIndent);
100
- }
101
- // Format nested suites
102
- for (const childSuite of suite.suites) {
103
- result += '\n' + formatSuiteResult(childSuite, childIndent);
104
- }
105
- return result;
106
- };
107
- const getTestSummary = (suite) => {
108
- let passed = 0, failed = 0, skipped = 0, todo = 0;
109
- // Count tests in current suite
110
- for (const test of suite.tests) {
111
- switch (test.status) {
112
- case 'passed':
113
- passed++;
114
- break;
115
- case 'failed':
116
- failed++;
117
- break;
118
- case 'skipped':
119
- skipped++;
120
- break;
121
- case 'todo':
122
- todo++;
123
- break;
124
- }
125
- }
126
- // Count tests in nested suites
127
- for (const childSuite of suite.suites) {
128
- const childSummary = getTestSummary(childSuite);
129
- passed += childSummary.passed;
130
- failed += childSummary.failed;
131
- skipped += childSummary.skipped;
132
- todo += childSummary.todo;
133
- }
134
- return { passed, failed, skipped, todo };
135
- };
@@ -1,95 +0,0 @@
1
- import { defaultReporter } from './src/reporters/default-reporter.js';
2
- // Sample test results to demonstrate the new styling
3
- const sampleResults = [
4
- {
5
- name: 'User Authentication Tests',
6
- status: 'passed',
7
- duration: 1250,
8
- tests: [
9
- {
10
- name: 'should login with valid credentials',
11
- status: 'passed',
12
- duration: 450,
13
- },
14
- {
15
- name: 'should show error with invalid credentials',
16
- status: 'passed',
17
- duration: 320,
18
- },
19
- {
20
- name: 'should handle network errors gracefully',
21
- status: 'failed',
22
- duration: 180,
23
- error: {
24
- name: 'NetworkError',
25
- message: 'Connection timeout after 30 seconds',
26
- stack: 'NetworkError: Connection timeout after 30 seconds\n at fetch (native)\n at login (auth.js:15:10)',
27
- },
28
- },
29
- ],
30
- suites: [],
31
- },
32
- {
33
- name: 'Navigation Tests',
34
- status: 'passed',
35
- duration: 890,
36
- tests: [
37
- {
38
- name: 'should navigate to home screen',
39
- status: 'passed',
40
- duration: 210,
41
- },
42
- {
43
- name: 'should navigate to profile screen',
44
- status: 'skipped',
45
- duration: 0,
46
- },
47
- {
48
- name: 'should handle deep linking',
49
- status: 'todo',
50
- duration: 0,
51
- },
52
- ],
53
- suites: [],
54
- },
55
- {
56
- name: 'Component Tests',
57
- status: 'failed',
58
- duration: 650,
59
- tests: [
60
- {
61
- name: 'should render button correctly',
62
- status: 'passed',
63
- duration: 120,
64
- },
65
- {
66
- name: 'should handle button press',
67
- status: 'failed',
68
- duration: 95,
69
- error: {
70
- name: 'AssertionError',
71
- message: 'Expected element to be visible but it was not found',
72
- stack: 'AssertionError: Expected element to be visible but it was not found\n at expect (test-utils.js:25:10)',
73
- },
74
- },
75
- ],
76
- suites: [
77
- {
78
- name: 'Nested Component Tests',
79
- status: 'passed',
80
- duration: 280,
81
- tests: [
82
- {
83
- name: 'should render nested component',
84
- status: 'passed',
85
- duration: 150,
86
- },
87
- ],
88
- suites: [],
89
- },
90
- ],
91
- },
92
- ];
93
- // Run the demo
94
- console.log('๐Ÿงช Testing Updated Default Reporter\n');
95
- await defaultReporter.report(sampleResults);
@@ -1,27 +0,0 @@
1
- import type { BridgeEvents } from '@react-native-harness/bridge';
2
- /**
3
- * Type-safe status line formatter for bridge events.
4
- * This ensures every event type has a corresponding status message.
5
- *
6
- * When adding new events to BridgeEvents:
7
- * 1. Add the event type to the appropriate events file in packages/bridge/src/shared/
8
- * 2. Add a formatter function to the statusFormatter object below
9
- * 3. TypeScript will enforce that all event types are covered
10
- * 4. The formatter function receives the full event data for type safety
11
- */
12
- export type StatusFormatter = {
13
- [K in BridgeEvents['type']]: (event: Extract<BridgeEvents, {
14
- type: K;
15
- }>) => string;
16
- };
17
- /**
18
- * Maps every bridge event to a concise, informative status line.
19
- * Each formatter receives the full event data for type safety.
20
- */
21
- export declare const statusFormatter: StatusFormatter;
22
- /**
23
- * Formats a bridge event into a status line.
24
- * This function is type-safe and ensures all event types are handled.
25
- */
26
- export declare const formatEventStatus: (event: BridgeEvents) => string;
27
- //# sourceMappingURL=status-formatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/status-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG;KAC3B,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,GAAG,CAC3B,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KACtC,MAAM;CACZ,CAAC;AAcF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,eAkD7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,YAAY,KAAG,MAGvD,CAAC"}
@@ -1,54 +0,0 @@
1
- const formatDuration = (duration) => {
2
- if (duration < 1000) {
3
- return `${duration}ms`;
4
- }
5
- return `${(duration / 1000).toFixed(2)}s`;
6
- };
7
- const formatFileName = (file) => {
8
- // Extract just the filename from the path for cleaner display
9
- return file.split('/').pop() || file;
10
- };
11
- /**
12
- * Maps every bridge event to a concise, informative status line.
13
- * Each formatter receives the full event data for type safety.
14
- */
15
- export const statusFormatter = {
16
- // Test Collection Events
17
- 'collection-started': (event) => `๐Ÿ“‹ Collecting tests from ${formatFileName(event.file)}`,
18
- 'collection-finished': (event) => `โœ… Collected tests from ${formatFileName(event.file)} (${formatDuration(event.duration)})`,
19
- // Test Runner Events
20
- 'file-started': (event) => `๐Ÿงช Running tests in ${formatFileName(event.file)}`,
21
- 'file-finished': (event) => `โœ… Finished ${formatFileName(event.file)} (${formatDuration(event.duration)})`,
22
- 'suite-started': (event) => `๐Ÿ“ฆ ${event.name}`,
23
- 'suite-finished': (event) => {
24
- const icon = event.status === 'failed'
25
- ? 'โŒ'
26
- : event.status === 'skipped'
27
- ? 'โญ๏ธ'
28
- : 'โœ…';
29
- return `${icon} ${event.name} (${formatDuration(event.duration)})`;
30
- },
31
- 'test-started': (event) => ` ๐Ÿ”„ ${event.name}`,
32
- 'test-finished': (event) => {
33
- const icon = event.status === 'failed'
34
- ? 'โŒ'
35
- : event.status === 'skipped'
36
- ? 'โญ๏ธ'
37
- : event.status === 'todo'
38
- ? '๐Ÿ“'
39
- : 'โœ…';
40
- return ` ${icon} ${event.name} (${formatDuration(event.duration)})`;
41
- },
42
- // Bundler Events
43
- 'module-bundling-started': (event) => `๐Ÿ“ฆ Bundling ${formatFileName(event.file)}`,
44
- 'module-bundling-finished': (event) => `โœ… Bundled ${formatFileName(event.file)} (${formatDuration(event.duration)})`,
45
- 'module-bundling-failed': (event) => `โŒ Failed to bundle ${formatFileName(event.file)} (${formatDuration(event.duration)})`,
46
- };
47
- /**
48
- * Formats a bridge event into a status line.
49
- * This function is type-safe and ensures all event types are handled.
50
- */
51
- export const formatEventStatus = (event) => {
52
- // TypeScript ensures this covers all event types
53
- return statusFormatter[event.type](event);
54
- };
package/dist/utils.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare function assert(condition: boolean, message: string): asserts condition;
2
- export declare class AssertionError extends Error {
3
- constructor(message: string);
4
- }
5
- export declare const isPortAvailable: (port: number) => Promise<boolean>;
6
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAI7E;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAa7D,CAAC"}
package/dist/utils.js DELETED
@@ -1,26 +0,0 @@
1
- import net from 'node:net';
2
- export function assert(condition, message) {
3
- if (!condition) {
4
- throw new AssertionError(message);
5
- }
6
- }
7
- export class AssertionError extends Error {
8
- constructor(message) {
9
- super(message);
10
- this.name = 'AssertionError';
11
- }
12
- }
13
- export const isPortAvailable = (port) => {
14
- return new Promise((resolve) => {
15
- const server = net.createServer();
16
- server.once('error', () => {
17
- server.close();
18
- resolve(false);
19
- });
20
- server.once('listening', () => {
21
- server.close();
22
- resolve(true);
23
- });
24
- server.listen(port);
25
- });
26
- };