diff options
Diffstat (limited to 'cli/tools/test_runner.rs')
-rw-r--r-- | cli/tools/test_runner.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index 6089d10a9..e74fad1f8 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -406,6 +406,24 @@ pub async fn run_tests( } for block in blocks_regex.captures_iter(&comment.text) { + let maybe_attributes = block.get(1).map(|m| m.as_str().split(' ')); + let media_type = if let Some(mut attributes) = maybe_attributes { + match attributes.next() { + Some("js") => MediaType::JavaScript, + Some("jsx") => MediaType::Jsx, + Some("ts") => MediaType::TypeScript, + Some("tsx") => MediaType::Tsx, + Some("") => file.media_type, + _ => MediaType::Unknown, + } + } else { + file.media_type + }; + + if media_type == MediaType::Unknown { + continue; + } + let body = block.get(2).unwrap(); let text = body.as_str(); @@ -425,16 +443,17 @@ pub async fn run_tests( let location = parsed_module.get_location(&span); let specifier = deno_core::resolve_url_or_path(&format!( - "{}${}-{}", + "{}${}-{}{}", location.filename, location.line, location.line + element.as_str().split('\n').count(), + media_type.as_ts_extension(), ))?; let file = File { local: specifier.to_file_path().unwrap(), maybe_types: None, - media_type: MediaType::TypeScript, // media_type.clone(), + media_type, source: source.clone(), specifier: specifier.clone(), }; |