File tree 3 files changed +41
-1
lines changed
3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,11 @@ impl crate::worker::CoverageCollector for CoverageCollector {
68
68
69
69
let script_coverages = self . take_precise_coverage ( ) . await ?. result ;
70
70
for script_coverage in script_coverages {
71
- // Filter out internal JS files from being included in coverage reports
71
+ // Filter out internal and http/https JS files from being included in coverage reports
72
72
if script_coverage. url . starts_with ( "ext:" )
73
73
|| script_coverage. url . starts_with ( "[ext:" )
74
+ || script_coverage. url . starts_with ( "http:" )
75
+ || script_coverage. url . starts_with ( "https:" )
74
76
|| script_coverage. url . starts_with ( "node:" )
75
77
{
76
78
continue ;
Original file line number Diff line number Diff line change @@ -439,6 +439,39 @@ fn no_internal_node_code() {
439
439
}
440
440
}
441
441
442
+ #[ test]
443
+ fn no_http_coverage_data ( ) {
444
+ let _http_server_guard = test_util:: http_server ( ) ;
445
+ let context = TestContext :: default ( ) ;
446
+ let tempdir = context. temp_dir ( ) ;
447
+ let tempdir = tempdir. path ( ) . join ( "cov" ) ;
448
+
449
+ let output = context
450
+ . new_command ( )
451
+ . args_vec ( vec ! [
452
+ "test" . to_string( ) ,
453
+ "--quiet" . to_string( ) ,
454
+ "--no-check" . to_string( ) ,
455
+ format!( "--coverage={}" , tempdir) ,
456
+ "coverage/no_http_coverage_data_test.ts" . to_string( ) ,
457
+ ] )
458
+ . run ( ) ;
459
+
460
+ output. assert_exit_code ( 0 ) ;
461
+ output. skip_output_check ( ) ;
462
+
463
+ // Check that coverage files contain no http urls
464
+ let paths = tempdir. read_dir ( ) ;
465
+ for path in paths {
466
+ let unwrapped = PathRef :: new ( path. unwrap ( ) . path ( ) ) ;
467
+ let data = unwrapped. read_to_string ( ) ;
468
+
469
+ let value: serde_json:: Value = serde_json:: from_str ( & data) . unwrap ( ) ;
470
+ let url = value[ "url" ] . as_str ( ) . unwrap ( ) ;
471
+ assert_starts_with ! ( url, "file:" ) ;
472
+ }
473
+ }
474
+
442
475
#[ test]
443
476
fn test_html_reporter ( ) {
444
477
// This test case generates a html coverage report of test cases in /tests/testdata/coverage/multisource
Original file line number Diff line number Diff line change
1
+ import "http://localhost:4546/run/001_hello.js" ;
2
+
3
+ Deno . test ( "hello" , ( ) => {
4
+ console . log ( "hello" ) ;
5
+ } ) ;
You can’t perform that action at this time.
0 commit comments