{#- TypeScript test case (it() block) template

   Context variables:
   - test_name: sanitized test name
   - description: fixture description with escaped quotes
   - async_kw: "async " (or empty string)
   - client_setup: client instantiation code (or empty string)
   - setup_lines: array of setup statement strings
   - call_expr: function call expression
   - has_usable_assertion: bool
   - result_var: result variable name
   - await_kw: "await " (or empty string)
   - assertions_body: string containing all rendered assertions
   - expects_error: bool
   - is_streaming_error_call: bool — streaming function called with error fixture;
       drain with `for await` so the lazy NAPI stream surfaces the error
   - skip_reason: optional string reason for skipping the test
   - bridge_cleanup: optional string for async trait bridge dispose() calls
#}
{%- if skip_reason %}
	it.skip("{{ test_name }}: {{ description }}", () => {
		// {{ skip_reason }}
	});
{%- elif expects_error %}
	it("{{ test_name }}: {{ description }}", async () => {
{% if client_setup %}
		{{ client_setup }}
{% endif %}
		await expect(async () => {
{% for line in setup_lines %}
			{{ line }}
{% endfor %}
{% if is_streaming_error_call %}
			const _stream = await {{ call_expr }};
{% if lang == "wasm" %}
			while (true) {
				const _ = await _stream.next();
				if (_ == null) break;
				/* drain to surface HTTP errors */
			}
{% else %}
			for await (const _ of _stream) {
				/* drain to surface HTTP errors */
			}
{% endif %}
{% else %}
			await {{ call_expr }};
{% endif %}
		}).rejects.toThrow();
	}, {{ timeout_ms }});
{%- else %}
	it("{{ test_name }}: {{ description }}", {{ async_kw }}() => {
{% if client_setup %}
		{{ client_setup }}
{% endif %}
{% for line in setup_lines %}
		{{ line }}
{% endfor %}
{% if has_usable_assertion %}
		const {{ result_var }} = {{ await_kw }}{{ call_expr }};
{% else %}
		{{ await_kw }}{{ call_expr }};
{% endif %}
{% if collect_snippet %}
		{{ collect_snippet }}
{% endif %}
{{ assertions_body }}
{%- if bridge_cleanup %}
		{{ bridge_cleanup }}
{%- endif %}
	}, {{ timeout_ms }});
{%- endif %}
