@react-native-harness/jest 1.4.0-rc.1 → 1.4.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 (75) hide show
  1. package/dist/__tests__/bridge.test.js +6 -2
  2. package/dist/__tests__/crash-monitor.test.js +64 -0
  3. package/dist/__tests__/environment-reset.test.d.ts +2 -0
  4. package/dist/__tests__/environment-reset.test.d.ts.map +1 -0
  5. package/dist/__tests__/environment-reset.test.js +238 -0
  6. package/dist/__tests__/execute-run.test.js +250 -4
  7. package/dist/__tests__/format-harness-error.test.d.ts +2 -0
  8. package/dist/__tests__/format-harness-error.test.d.ts.map +1 -0
  9. package/dist/__tests__/format-harness-error.test.js +27 -0
  10. package/dist/__tests__/harness-cache.test.js +62 -41
  11. package/dist/__tests__/harness-session-signal.test.d.ts +2 -0
  12. package/dist/__tests__/harness-session-signal.test.d.ts.map +1 -0
  13. package/dist/__tests__/harness-session-signal.test.js +298 -0
  14. package/dist/__tests__/harness-session.test.js +161 -2
  15. package/dist/__tests__/index.test.js +3 -1
  16. package/dist/__tests__/metro-port.test.js +2 -0
  17. package/dist/__tests__/run.test.d.ts +2 -0
  18. package/dist/__tests__/run.test.d.ts.map +1 -0
  19. package/dist/__tests__/run.test.js +48 -0
  20. package/dist/crash-monitor.d.ts +7 -0
  21. package/dist/crash-monitor.d.ts.map +1 -1
  22. package/dist/crash-monitor.js +19 -0
  23. package/dist/diagnostics/__tests__/derivers.test.d.ts +2 -0
  24. package/dist/diagnostics/__tests__/derivers.test.d.ts.map +1 -0
  25. package/dist/diagnostics/__tests__/derivers.test.js +248 -0
  26. package/dist/diagnostics/__tests__/report.test.d.ts +2 -0
  27. package/dist/diagnostics/__tests__/report.test.d.ts.map +1 -0
  28. package/dist/diagnostics/__tests__/report.test.js +97 -0
  29. package/dist/diagnostics/derivers.d.ts +24 -0
  30. package/dist/diagnostics/derivers.d.ts.map +1 -0
  31. package/dist/diagnostics/derivers.js +146 -0
  32. package/dist/diagnostics/index.d.ts +3 -0
  33. package/dist/diagnostics/index.d.ts.map +1 -0
  34. package/dist/diagnostics/index.js +2 -0
  35. package/dist/diagnostics/report.d.ts +7 -0
  36. package/dist/diagnostics/report.d.ts.map +1 -0
  37. package/dist/diagnostics/report.js +84 -0
  38. package/dist/environment-reset.d.ts +51 -0
  39. package/dist/environment-reset.d.ts.map +1 -0
  40. package/dist/environment-reset.js +83 -0
  41. package/dist/execute-run.d.ts.map +1 -1
  42. package/dist/execute-run.js +121 -69
  43. package/dist/format-harness-error.d.ts +5 -0
  44. package/dist/format-harness-error.d.ts.map +1 -0
  45. package/dist/format-harness-error.js +43 -0
  46. package/dist/harness-session.d.ts +26 -1
  47. package/dist/harness-session.d.ts.map +1 -1
  48. package/dist/harness-session.js +260 -87
  49. package/dist/run.d.ts.map +1 -1
  50. package/dist/run.js +21 -4
  51. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  52. package/package.json +8 -7
  53. package/src/__tests__/bridge.test.ts +8 -3
  54. package/src/__tests__/crash-monitor.test.ts +84 -0
  55. package/src/__tests__/environment-reset.test.ts +308 -0
  56. package/src/__tests__/execute-run.test.ts +327 -4
  57. package/src/__tests__/format-harness-error.test.ts +32 -0
  58. package/src/__tests__/harness-cache.test.ts +91 -0
  59. package/src/__tests__/harness-session.test.ts +211 -1
  60. package/src/__tests__/index.test.ts +3 -1
  61. package/src/__tests__/metro-port.test.ts +2 -0
  62. package/src/__tests__/run.test.ts +74 -0
  63. package/src/crash-monitor.ts +28 -0
  64. package/src/diagnostics/__tests__/derivers.test.ts +300 -0
  65. package/src/diagnostics/__tests__/report.test.ts +128 -0
  66. package/src/diagnostics/derivers.ts +170 -0
  67. package/src/diagnostics/index.ts +2 -0
  68. package/src/diagnostics/report.ts +124 -0
  69. package/src/environment-reset.ts +138 -0
  70. package/src/execute-run.ts +136 -77
  71. package/src/format-harness-error.ts +73 -0
  72. package/src/harness-session.ts +369 -131
  73. package/src/run.ts +23 -4
  74. package/tsconfig.json +3 -0
  75. package/tsconfig.lib.json +3 -0
package/src/run.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  import type { HarnessSession } from './harness-session.js';
9
9
  import { formatResultsErrors } from 'jest-message-util';
10
10
  import { toTestResult } from './toTestResult.js';
11
+ import { formatHarnessErrorMessage } from './format-harness-error.js';
11
12
 
12
13
  // Helper function to flatten nested test suites into a flat array of tests with hierarchy
13
14
  const flattenTests = (
@@ -16,6 +17,17 @@ const flattenTests = (
16
17
  ): Array<HarnessTestResult & { ancestorTitles: string[] }> => {
17
18
  const tests: Array<HarnessTestResult & { ancestorTitles: string[] }> = [];
18
19
 
20
+ if (suiteResult.error) {
21
+ tests.push({
22
+ name: suiteResult.name,
23
+ status: 'failed',
24
+ duration: suiteResult.duration,
25
+ error: suiteResult.error,
26
+ ancestorTitles: [...ancestorTitles],
27
+ fullName: [...ancestorTitles, suiteResult.name].join(' '),
28
+ });
29
+ }
30
+
19
31
  // Add tests from current suite with current hierarchy
20
32
  for (const test of suiteResult.tests) {
21
33
  tests.push({
@@ -88,11 +100,18 @@ export const runHarnessTestFile: RunHarnessTestFile = async ({
88
100
  const setupFilesAfterEnv = projectConfig.setupFilesAfterEnv?.map(
89
101
  (setupFile) => path.relative(globalConfig.rootDir, setupFile)
90
102
  );
103
+ const testTimeout =
104
+ session.config.testTimeout ??
105
+ (projectConfig as JestConfig.ProjectConfig & { testTimeout?: number })
106
+ .testTimeout ??
107
+ (globalConfig as JestConfig.GlobalConfig & { testTimeout?: number })
108
+ .testTimeout;
91
109
 
92
110
  const harnessResult = await session.runTestFile(relativeTestPath, {
93
111
  testNamePattern: globalConfig.testNamePattern,
94
112
  setupFiles,
95
113
  setupFilesAfterEnv,
114
+ testTimeout,
96
115
  runner: session.context.platform.runner,
97
116
  });
98
117
  const end = Date.now();
@@ -102,14 +121,14 @@ export const runHarnessTestFile: RunHarnessTestFile = async ({
102
121
 
103
122
  // Convert TestResult[] to the format expected by toTestResult
104
123
  const tests = allTests.map((test) => {
105
- const errorMessage = test.error?.message;
106
124
  const codeFrame = test.error?.codeFrame;
125
+ const errorMessage = formatHarnessErrorMessage(test.error, {
126
+ testStartedAt: test.startedAt,
127
+ });
107
128
 
108
129
  return {
109
130
  duration: test.duration,
110
- errorMessage: errorMessage
111
- ? `${errorMessage}${codeFrame ? `\n\n${codeFrame.content}` : ''}`
112
- : undefined,
131
+ errorMessage,
113
132
  title: test.name,
114
133
  fullName: test.fullName,
115
134
  status: test.status,
package/tsconfig.json CHANGED
@@ -6,6 +6,9 @@
6
6
  {
7
7
  "path": "../tools"
8
8
  },
9
+ {
10
+ "path": "../cache"
11
+ },
9
12
  {
10
13
  "path": "../platforms"
11
14
  },
package/tsconfig.lib.json CHANGED
@@ -15,6 +15,9 @@
15
15
  {
16
16
  "path": "../tools/tsconfig.lib.json"
17
17
  },
18
+ {
19
+ "path": "../cache/tsconfig.lib.json"
20
+ },
18
21
  {
19
22
  "path": "../platforms/tsconfig.lib.json"
20
23
  },