Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/example/rn-harness.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const config = {
],
defaultRunner: 'android',
resetEnvironmentBetweenTestFiles: 'runtime',
testTimeout: process.env.CI === 'true' ? 30000 : 10000,
// The async HybridObject stress test has its own 120-second deadline.
testTimeout: process.env.CI === 'true' ? 150000 : 10000,
platformReadyTimeout: process.env.CI === 'true' ? 420000 : 300000,
bridgeTimeout: process.env.CI === 'true' ? 180000 : 60000,
bundleStartTimeout: process.env.CI === 'true' ? 120000 : 60000,
Expand Down
3 changes: 2 additions & 1 deletion apps/example/src/getTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface TestRunner {
// 2) In JVM, 51_200 is the limit for `jni::global_ref`s, then the app crashes - this intentionally exhausts that
const MEMORY_LEAK_TEST_ALLOCATION_COUNT = 55_000
const EXTERNAL_MEMORY_TEST_SIZE = 1024 * 1024
const PARALLEL_HYBRID_OBJECT_TEST_TIMEOUT = 120_000

type HermesInternal = {
getInstrumentedStats?: () => { js_externalBytes: number }
Expand Down Expand Up @@ -1549,7 +1550,7 @@ export function getTests(
)
}
return true
})
}, PARALLEL_HYBRID_OBJECT_TEST_TIMEOUT)
)
.didNotThrow()
.equals(true)
Expand Down
15 changes: 9 additions & 6 deletions apps/example/src/testing/createTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ function timeoutedPromise<T>(
}

export interface TestRunner {
it<T>(action: () => Promise<T>): Promise<State<T>>
it<T>(action: () => T): State<T>
it<T>(action: () => Promise<T>, timeout?: number): Promise<State<T>>
it<T>(action: () => T, timeout?: number): State<T>
}

/**
* Creates a test runner with the provided assertion backend.
*/
export function createTestRunner(backend: AssertionBackend): TestRunner {
function it<T>(action: () => Promise<T>): Promise<State<T>>
function it<T>(action: () => T): State<T>
function it<T>(action: () => T | Promise<T>): State<T> | Promise<State<T>> {
function it<T>(action: () => Promise<T>, timeout?: number): Promise<State<T>>
function it<T>(action: () => T, timeout?: number): State<T>
function it<T>(
action: () => T | Promise<T>,
timeout?: number
): State<T> | Promise<State<T>> {
try {
const syncResult = action()
if (syncResult instanceof Promise) {
const wrapped = timeoutedPromise<T>(syncResult)
const wrapped = timeoutedPromise<T>(syncResult, timeout)
return wrapped
.then((asyncResult) => new State<T>(asyncResult, undefined, backend))
.catch((error) => new State<T>(undefined, error, backend))
Expand Down
Loading