Skip to content

Commit

Permalink
fix unhandled error
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 3, 2024
1 parent 1f1a0bd commit d96cbc1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/environment/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ const listener: EnvironmentListenerFn = (context) => {
.on('test_environment_setup', setWorkerId)
.on('add_hook', addHookType)
.on('add_hook', addSourceLocation)
.on('add_hook', addSourceCode)
.on('add_test', addSourceLocation)
.on('add_test', addSourceCode)
.on('run_start', flush)
.on('hook_start', addSourceCode)
.on('hook_start', executableStart)
.on('hook_failure', executableFailure)
.on('hook_failure', flush)
Expand All @@ -29,7 +30,6 @@ const listener: EnvironmentListenerFn = (context) => {
.on('test_todo', testSkip)
.on('test_skip', testSkip)
.on('test_done', testDone)
.on('test_fn_start', addSourceCode)
.on('test_fn_start', executableStart)
.on('test_fn_success', executableSuccess)
.on('test_fn_success', flush)
Expand Down Expand Up @@ -93,9 +93,9 @@ function addHookType({ event }: TestEnvironmentCircusEvent<Circus.Event & { name

function addSourceCode({ event }: TestEnvironmentCircusEvent) {
let code = '';
if (event.name === 'hook_start') {
const { type, fn } = event.hook;
code = `${type}(${fn});`;
if (event.name === 'add_hook') {
const { hookType, fn } = event;
code = `${hookType}(${fn});`;

if (code.includes("during setup, this cannot be null (and it's fine to explode if it is)")) {
code = '';
Expand All @@ -105,9 +105,9 @@ function addSourceCode({ event }: TestEnvironmentCircusEvent) {
}
}

if (event.name === 'test_fn_start') {
const { name, fn } = event.test;
code = `test(${JSON.stringify(name)}, ${fn});`;
if (event.name === 'add_test') {
const { testName, fn } = event;
code = `test(${JSON.stringify(testName)}, ${fn});`;
}

if (code) {
Expand Down
6 changes: 4 additions & 2 deletions src/reporter/resolveTestItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function resolvePromisedTestCase<
return;
}

return resolvePromisedProperties(promisedItem);
return await resolvePromisedProperties(promisedItem);
} catch (error: unknown) {
log.error(error, 'Failed to report test case');
return;
Expand All @@ -32,7 +32,9 @@ export async function resolvePromisedItem<Context, ResultKey extends keyof Conte
extractor: PropertyExtractor<Context, PromisedProperties<Result>>,
resultKey: ResultKey,
): Promise<Result> {
return resolvePromisedProperties<Result>(preparePromisedItem(context, extractor, resultKey));
return await resolvePromisedProperties<Result>(
preparePromisedItem(context, extractor, resultKey),
);
}

function preparePromisedItem<Context, ResultKey extends keyof Context, Result>(
Expand Down

0 comments on commit d96cbc1

Please sign in to comment.