Skip to content

Commit 2409720

Browse files
Copilot9aoy
andcommitted
feat: apply globals option consistently to all rstest methods
Co-authored-by: 9aoy <[email protected]>
1 parent df634de commit 2409720

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/rspack_plugin_rstest/src/parser_plugin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ impl RstestParserPlugin {
568568
prop: &swc_core::ecma::ast::IdentName,
569569
statement_span: Option<Span>,
570570
) -> Option<bool> {
571+
// Check if this is a global variable (free variable) or an ESM import
572+
let is_global = !parser.is_variable_defined(&ident.sym);
573+
574+
// Skip global variables if globals option is disabled
575+
if is_global && !self.globals {
576+
return None;
577+
}
578+
571579
match (ident.sym.as_str(), prop.sym.as_str()) {
572580
// rs.mock
573581
("rs" | "rstest", "mock") => {

0 commit comments

Comments
 (0)