Skip to content

Commit 94fed60

Browse files
committed
test: Add
1 parent 15c713a commit 94fed60

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

crates/wasm-workers/src/workflow/workflow_js_worker.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,33 @@ mod tests {
632632
assert_eq!(extract_string(&ok_val.value), "hello world");
633633
}
634634

635+
#[tokio::test]
636+
async fn async_fn_should_fail() {
637+
test_utils::set_up();
638+
let ffqn = FunctionFqn::new_static("test:pkg/ifc", "hello");
639+
let js_source = r#"
640+
export default async function hello() {
641+
return "hello world";
642+
}
643+
"#;
644+
645+
let worker = new_js_workflow_worker(js_source, &ffqn);
646+
let ctx = make_worker_context(ffqn, &[]);
647+
648+
let err = worker.run(ctx).await.unwrap_err();
649+
assert_matches!(
650+
err,
651+
WorkerError::FatalError(
652+
FatalError::ResultParsingError(ResultParsingError::ResultParsingErrorFromVal(
653+
ResultParsingErrorFromVal::TypeCheckError(reason),
654+
)),
655+
_version,
656+
) => {
657+
assert!(reason.starts_with("expected string, got JsValue"), "reason: {reason}");
658+
}
659+
);
660+
}
661+
635662
#[tokio::test]
636663
async fn workflow_js_with_params() {
637664
test_utils::set_up();

0 commit comments

Comments
 (0)