react-native-harness 1.0.0-alpha.5 → 1.0.0-alpha.7

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 (111) hide show
  1. package/README.md +2 -2
  2. package/bin.js +1 -1
  3. package/dist/babel.d.ts +2 -0
  4. package/dist/babel.d.ts.map +1 -0
  5. package/dist/babel.js +1 -0
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -37
  9. package/dist/metro.d.ts +2 -0
  10. package/dist/metro.d.ts.map +1 -0
  11. package/dist/metro.js +1 -0
  12. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  13. package/eslint.config.mjs +1 -1
  14. package/package.json +31 -12
  15. package/src/babel.ts +1 -0
  16. package/src/index.ts +1 -52
  17. package/src/metro.ts +1 -0
  18. package/tsconfig.json +9 -3
  19. package/tsconfig.lib.json +8 -14
  20. package/types/index.d.ts +1 -0
  21. package/dist/bundlers/metro.d.ts +0 -5
  22. package/dist/bundlers/metro.d.ts.map +0 -1
  23. package/dist/bundlers/metro.js +0 -61
  24. package/dist/bundlers/webpack.d.ts +0 -2
  25. package/dist/bundlers/webpack.d.ts.map +0 -1
  26. package/dist/bundlers/webpack.js +0 -49
  27. package/dist/commands/test.d.ts +0 -2
  28. package/dist/commands/test.d.ts.map +0 -1
  29. package/dist/commands/test.js +0 -138
  30. package/dist/errors/appNotInstalledError.d.ts +0 -7
  31. package/dist/errors/appNotInstalledError.d.ts.map +0 -1
  32. package/dist/errors/appNotInstalledError.js +0 -12
  33. package/dist/errors/bridgeTimeoutError.d.ts +0 -7
  34. package/dist/errors/bridgeTimeoutError.d.ts.map +0 -1
  35. package/dist/errors/bridgeTimeoutError.js +0 -12
  36. package/dist/errors/errorHandler.d.ts +0 -2
  37. package/dist/errors/errorHandler.d.ts.map +0 -1
  38. package/dist/errors/errorHandler.js +0 -150
  39. package/dist/errors/errors.d.ts +0 -46
  40. package/dist/errors/errors.d.ts.map +0 -1
  41. package/dist/errors/errors.js +0 -93
  42. package/dist/platforms/android/build.d.ts +0 -5
  43. package/dist/platforms/android/build.d.ts.map +0 -1
  44. package/dist/platforms/android/build.js +0 -29
  45. package/dist/platforms/android/device.d.ts +0 -5
  46. package/dist/platforms/android/device.d.ts.map +0 -1
  47. package/dist/platforms/android/device.js +0 -36
  48. package/dist/platforms/android/emulator.d.ts +0 -11
  49. package/dist/platforms/android/emulator.d.ts.map +0 -1
  50. package/dist/platforms/android/emulator.js +0 -110
  51. package/dist/platforms/android/index.d.ts +0 -4
  52. package/dist/platforms/android/index.d.ts.map +0 -1
  53. package/dist/platforms/android/index.js +0 -56
  54. package/dist/platforms/ios/build.d.ts +0 -7
  55. package/dist/platforms/ios/build.d.ts.map +0 -1
  56. package/dist/platforms/ios/build.js +0 -44
  57. package/dist/platforms/ios/device.d.ts +0 -7
  58. package/dist/platforms/ios/device.d.ts.map +0 -1
  59. package/dist/platforms/ios/device.js +0 -51
  60. package/dist/platforms/ios/index.d.ts +0 -4
  61. package/dist/platforms/ios/index.d.ts.map +0 -1
  62. package/dist/platforms/ios/index.js +0 -43
  63. package/dist/platforms/ios/simulator.d.ts +0 -11
  64. package/dist/platforms/ios/simulator.d.ts.map +0 -1
  65. package/dist/platforms/ios/simulator.js +0 -124
  66. package/dist/platforms/platform-adapter.d.ts +0 -10
  67. package/dist/platforms/platform-adapter.d.ts.map +0 -1
  68. package/dist/platforms/platform-adapter.js +0 -1
  69. package/dist/platforms/platform-registry.d.ts +0 -3
  70. package/dist/platforms/platform-registry.d.ts.map +0 -1
  71. package/dist/platforms/platform-registry.js +0 -19
  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.d.ts +0 -5
  90. package/dist/utils.d.ts.map +0 -1
  91. package/dist/utils.js +0 -11
  92. package/src/bundlers/metro.ts +0 -89
  93. package/src/commands/test.ts +0 -221
  94. package/src/errors/errorHandler.ts +0 -196
  95. package/src/errors/errors.ts +0 -119
  96. package/src/platforms/android/build.ts +0 -48
  97. package/src/platforms/android/device.ts +0 -48
  98. package/src/platforms/android/emulator.ts +0 -139
  99. package/src/platforms/android/index.ts +0 -87
  100. package/src/platforms/ios/build.ts +0 -68
  101. package/src/platforms/ios/device.ts +0 -76
  102. package/src/platforms/ios/index.ts +0 -66
  103. package/src/platforms/ios/simulator.ts +0 -166
  104. package/src/platforms/platform-adapter.ts +0 -11
  105. package/src/platforms/platform-registry.ts +0 -24
  106. package/src/platforms/web/index.ts +0 -16
  107. package/src/process.ts +0 -33
  108. package/src/reporters/default-reporter.ts +0 -149
  109. package/src/reporters/junit-reporter.ts +0 -179
  110. package/src/utils.ts +0 -12
  111. package/tsconfig.tsbuildinfo +0 -1
package/src/process.ts DELETED
@@ -1,33 +0,0 @@
1
- import { type ChildProcess } from 'node:child_process';
2
-
3
- export const killWithAwait = (child: ChildProcess): Promise<void> => {
4
- return new Promise((resolve) => {
5
- const timeout = setTimeout(() => {
6
- child.kill('SIGTERM');
7
- resolve();
8
- }, 10000);
9
-
10
- if (child.killed || child.exitCode !== null) {
11
- clearTimeout(timeout);
12
- resolve();
13
- return;
14
- }
15
-
16
- child.on('exit', () => {
17
- clearTimeout(timeout);
18
- resolve();
19
- });
20
-
21
- child.on('error', () => {
22
- clearTimeout(timeout);
23
- resolve();
24
- });
25
-
26
- try {
27
- child.kill();
28
- } catch (error) {
29
- clearTimeout(timeout);
30
- resolve();
31
- }
32
- });
33
- };
@@ -1,149 +0,0 @@
1
- import { color, spinner } from '@react-native-harness/tools';
2
- import type { TestSuiteResult, TestResult } from '@react-native-harness/bridge';
3
- import { Reporter } from '@react-native-harness/config';
4
-
5
- export const defaultReporter: Reporter = {
6
- report: async (results) => {
7
- const resultsSpinner = spinner();
8
- resultsSpinner.start('Test Results');
9
-
10
- for (const suite of results) {
11
- resultsSpinner.message(formatSuiteResult(suite));
12
- }
13
-
14
- // Summary
15
- let totalPassed = 0,
16
- totalFailed = 0,
17
- totalSkipped = 0,
18
- totalTodo = 0;
19
- let totalDuration = 0;
20
-
21
- for (const suite of results) {
22
- const summary = getTestSummary(suite);
23
- totalPassed += summary.passed;
24
- totalFailed += summary.failed;
25
- totalSkipped += summary.skipped;
26
- totalTodo += summary.todo;
27
- totalDuration += suite.duration || 0;
28
- }
29
-
30
- const summaryText = [
31
- color.green(`${totalPassed} passed`),
32
- color.red(`${totalFailed} failed`),
33
- color.yellow(`${totalSkipped} skipped`),
34
- color.blue(`${totalTodo} todo`),
35
- ].join(', ');
36
-
37
- resultsSpinner.message(`Summary: ${summaryText}`);
38
- resultsSpinner.message(`Total time: ${formatDuration(totalDuration)}`);
39
- },
40
- };
41
-
42
- const formatDuration = (duration?: number): string => {
43
- if (duration == null) return '';
44
- return color.dim(` (${duration}ms)`);
45
- };
46
-
47
- const getStatusIcon = (status: string): string => {
48
- switch (status) {
49
- case 'passed':
50
- return color.green('✓');
51
- case 'failed':
52
- return color.red('✗');
53
- case 'skipped':
54
- return color.yellow('○');
55
- case 'todo':
56
- return color.blue('◐');
57
- default:
58
- return '?';
59
- }
60
- };
61
-
62
- const formatTestResult = (test: TestResult, indent = ''): string => {
63
- const icon = getStatusIcon(test.status);
64
- const name = test.status === 'failed' ? color.red(test.name) : test.name;
65
- const duration = formatDuration(test.duration);
66
-
67
- let result = `${indent}${icon} ${name}${duration}`;
68
-
69
- if (test.error) {
70
- const errorLines = test.error.message?.split('\n') || [];
71
- result +=
72
- '\n' +
73
- errorLines
74
- .map((line: string) => `${indent} ${color.red(line)}`)
75
- .join('\n');
76
- }
77
-
78
- return result;
79
- };
80
-
81
- const formatSuiteResult = (suite: TestSuiteResult, indent = ''): string => {
82
- const icon = getStatusIcon(suite.status);
83
- const name =
84
- suite.status === 'failed' ? color.red(suite.name) : color.bold(suite.name);
85
- const duration = formatDuration(suite.duration);
86
-
87
- let result = `${indent}${icon} ${name}${duration}`;
88
-
89
- if (suite.error) {
90
- const errorLines = suite.error.message.split('\n');
91
- result +=
92
- '\n' +
93
- errorLines
94
- .map((line: string) => `${indent} ${color.red(line)}`)
95
- .join('\n');
96
- }
97
-
98
- const childIndent = indent + ' ';
99
-
100
- // Format tests
101
- for (const test of suite.tests) {
102
- result += '\n' + formatTestResult(test, childIndent);
103
- }
104
-
105
- // Format nested suites
106
- for (const childSuite of suite.suites) {
107
- result += '\n' + formatSuiteResult(childSuite, childIndent);
108
- }
109
-
110
- return result;
111
- };
112
-
113
- const getTestSummary = (
114
- suite: TestSuiteResult
115
- ): { passed: number; failed: number; skipped: number; todo: number } => {
116
- let passed = 0,
117
- failed = 0,
118
- skipped = 0,
119
- todo = 0;
120
-
121
- // Count tests in current suite
122
- for (const test of suite.tests) {
123
- switch (test.status) {
124
- case 'passed':
125
- passed++;
126
- break;
127
- case 'failed':
128
- failed++;
129
- break;
130
- case 'skipped':
131
- skipped++;
132
- break;
133
- case 'todo':
134
- todo++;
135
- break;
136
- }
137
- }
138
-
139
- // Count tests in nested suites
140
- for (const childSuite of suite.suites) {
141
- const childSummary = getTestSummary(childSuite);
142
- passed += childSummary.passed;
143
- failed += childSummary.failed;
144
- skipped += childSummary.skipped;
145
- todo += childSummary.todo;
146
- }
147
-
148
- return { passed, failed, skipped, todo };
149
- };
@@ -1,179 +0,0 @@
1
- import { Reporter } from '@react-native-harness/config';
2
- import type { TestSuiteResult, TestResult } from '@react-native-harness/bridge';
3
- import { writeFileSync } from 'fs';
4
- import { join } from 'path';
5
-
6
- export const junitReporter: Reporter = {
7
- report: async (results) => {
8
- const xml = generateJUnitXML(results);
9
-
10
- // Write to junit.xml file
11
- const outputPath = join(process.cwd(), 'junit.xml');
12
- writeFileSync(outputPath, xml, 'utf8');
13
-
14
- console.log(`📄 JUnit report written to: ${outputPath}`);
15
- },
16
- };
17
-
18
- const generateJUnitXML = (results: TestSuiteResult[]): string => {
19
- const { totalTests, totalFailures, totalSkipped, totalTime } =
20
- calculateTotals(results);
21
-
22
- let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
23
- xml += `<testsuites tests="${totalTests}" failures="${totalFailures}" skipped="${totalSkipped}" time="${
24
- totalTime / 1000
25
- }">\n`;
26
-
27
- for (const suite of results) {
28
- xml += generateTestSuiteXML(suite, ' ');
29
- }
30
-
31
- xml += '</testsuites>\n';
32
-
33
- return xml;
34
- };
35
-
36
- const generateTestSuiteXML = (
37
- suite: TestSuiteResult,
38
- indent: string
39
- ): string => {
40
- const { tests, failures, skipped, time } = getSuiteStats(suite);
41
-
42
- let xml = `${indent}<testsuite name="${escapeXML(
43
- suite.name
44
- )}" tests="${tests}" failures="${failures}" skipped="${skipped}" time="${
45
- time / 1000
46
- }"`;
47
-
48
- if (suite.error) {
49
- xml += ` errors="1"`;
50
- }
51
-
52
- xml += '>\n';
53
-
54
- // Add suite-level error if present
55
- if (suite.error) {
56
- xml += `${indent} <error message="${escapeXML(
57
- suite.error.message || 'Suite failed'
58
- )}"`;
59
- if (suite.error.name) {
60
- xml += ` type="${escapeXML(suite.error.name)}"`;
61
- }
62
- xml += '>';
63
- if (suite.error.stack) {
64
- xml += escapeXML(suite.error.stack);
65
- }
66
- xml += '</error>\n';
67
- }
68
-
69
- // Add individual test cases
70
- for (const test of suite.tests) {
71
- xml += generateTestCaseXML(test, indent + ' ');
72
- }
73
-
74
- // Add nested suites
75
- for (const nestedSuite of suite.suites) {
76
- xml += generateTestSuiteXML(nestedSuite, indent + ' ');
77
- }
78
-
79
- xml += `${indent}</testsuite>\n`;
80
-
81
- return xml;
82
- };
83
-
84
- const generateTestCaseXML = (test: TestResult, indent: string): string => {
85
- const time = (test.duration || 0) / 1000;
86
- let xml = `${indent}<testcase name="${escapeXML(test.name)}" time="${time}"`;
87
-
88
- if (test.status === 'passed') {
89
- xml += '/>\n';
90
- } else {
91
- xml += '>\n';
92
-
93
- switch (test.status) {
94
- case 'failed':
95
- xml += `${indent} <failure message="${escapeXML(
96
- test.error?.message || 'Test failed'
97
- )}"`;
98
- if (test.error?.name) {
99
- xml += ` type="${escapeXML(test.error.name)}"`;
100
- }
101
- xml += '>';
102
- if (test.error?.stack) {
103
- xml += escapeXML(test.error.stack);
104
- }
105
- xml += '</failure>\n';
106
- break;
107
- case 'skipped':
108
- xml += `${indent} <skipped/>\n`;
109
- break;
110
- case 'todo':
111
- xml += `${indent} <skipped message="TODO: Test not implemented"/>\n`;
112
- break;
113
- }
114
-
115
- xml += `${indent}</testcase>\n`;
116
- }
117
-
118
- return xml;
119
- };
120
-
121
- const calculateTotals = (
122
- results: TestSuiteResult[]
123
- ): {
124
- totalTests: number;
125
- totalFailures: number;
126
- totalSkipped: number;
127
- totalTime: number;
128
- } => {
129
- let totalTests = 0;
130
- let totalFailures = 0;
131
- let totalSkipped = 0;
132
- let totalTime = 0;
133
-
134
- for (const suite of results) {
135
- const stats = getSuiteStats(suite);
136
- totalTests += stats.tests;
137
- totalFailures += stats.failures;
138
- totalSkipped += stats.skipped;
139
- totalTime += stats.time;
140
- }
141
-
142
- return { totalTests, totalFailures, totalSkipped, totalTime };
143
- };
144
-
145
- const getSuiteStats = (
146
- suite: TestSuiteResult
147
- ): {
148
- tests: number;
149
- failures: number;
150
- skipped: number;
151
- time: number;
152
- } => {
153
- let tests = suite.tests.length;
154
- let failures = suite.tests.filter((t) => t.status === 'failed').length;
155
- let skipped = suite.tests.filter(
156
- (t) => t.status === 'skipped' || t.status === 'todo'
157
- ).length;
158
- let time = suite.duration || 0;
159
-
160
- // Add stats from nested suites
161
- for (const nestedSuite of suite.suites) {
162
- const nestedStats = getSuiteStats(nestedSuite);
163
- tests += nestedStats.tests;
164
- failures += nestedStats.failures;
165
- skipped += nestedStats.skipped;
166
- time += nestedStats.time;
167
- }
168
-
169
- return { tests, failures, skipped, time };
170
- };
171
-
172
- const escapeXML = (str: string): string => {
173
- return str
174
- .replace(/&/g, '&amp;')
175
- .replace(/</g, '&lt;')
176
- .replace(/>/g, '&gt;')
177
- .replace(/"/g, '&quot;')
178
- .replace(/'/g, '&apos;');
179
- };
package/src/utils.ts DELETED
@@ -1,12 +0,0 @@
1
- export function assert(condition: boolean, message: string): asserts condition {
2
- if (!condition) {
3
- throw new AssertionError(message);
4
- }
5
- }
6
-
7
- export class AssertionError extends Error {
8
- constructor(message: string) {
9
- super(message);
10
- this.name = 'AssertionError';
11
- }
12
- }
@@ -1 +0,0 @@
1
- {"fileNames":[],"fileInfos":[],"root":[],"options":{"composite":true,"declarationMap":true,"emitDeclarationOnly":true,"importHelpers":true,"module":199,"noEmitOnError":true,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUnusedLocals":true,"skipLibCheck":true,"strict":true,"target":9},"version":"5.8.3"}