{"record":{"id":"d7127f799fd346af","repo":"swc-project/swc","slug":"failed-to-execute-transfomred-code","errorCode":null,"errorMessage":"failed to execute transfomred code","messagePattern":"failed to execute transfomred code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_testing/src/babel_like.rs","lineNumber":202,"sourceCode":"                Color::Green.paint(\"Code\"),\n                code_without_helper\n            );\n\n            if let Some(output_path) = output_path {\n                // Fixture test\n\n                if !self.allow_error && handler.has_errors() {\n                    return Err(());\n                }\n\n                NormalizedOutput::from(code)\n                    .compare_to_file(output_path)\n                    .unwrap();\n            } else if compare_stdout {\n                // Execution test, but compare stdout\n\n                let actual_stdout: String =\n                    stdout_of(&code).expect(\"failed to execute transfomred code\");\n                let expected_stdout =\n                    stdout_of(&fm.src).expect(\"failed to execute transfomred code\");\n\n                testing::assert_eq!(actual_stdout, expected_stdout);\n            } else {\n                // Execution test\n\n                exec_with_node_test_runner(&format!(\"// {}\\n{code}\", self.input.display()))\n                    .expect(\"failed to execute transfomred code\");\n            }\n\n            Ok(())\n        });\n\n        if self.allow_error {\n            match err {\n                Ok(_) => {}\n                Err(err) => {","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_testing/src/babel_like.rs#L184-L220","documentation":"In the babel_like harness, execution tests that compare stdout first run the TRANSFORMED code through node via `stdout_of(&code)` (which delegates to `exec_node_js`). The `expect(\"failed to execute transfomred code\")` (typo intentional, it is in the source) fires when running the transformed output fails to produce stdout: node cannot be spawned or the transformed code crashes/errors when executed.","triggerScenarios":"A `compare_stdout`-style fixture where the transformed code throws at runtime (bad transform output, reference error, syntax the generated code uses but node rejects), or the `node` executable is missing from PATH in the test environment.","commonSituations":"Running execution tests (`EXEC != 0`) in CI images without node installed; a transform regression that emits broken code; transformed output using syntax newer than the installed node version.","solutions":["Run the failing fixture manually: the harness prints the transformed code; save it and run `node file.js` to see the real error.","Install node and ensure it is on PATH (`node --version` from the same shell that runs cargo).","If node is too old for the emitted syntax (e.g. top-level await, class fields), upgrade node.","Temporarily skip execution tests with `EXEC=0 cargo test` while diagnosing, then re-enable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Skip execution tests when node is unavailable.\nfn node_available() -> bool {\n    std::process::Command::new(\"node\")\n        .arg(\"--version\")\n        .output()\n        .map(|o| o.status.success())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure `node --version` works in the exact shell/CI step that runs cargo test.","Keep transformed output runnable on the installed node version (mind newer syntax features).","Use EXEC=0 to exclude execution tests in node-less environments."],"tags":["test-harness","node","execution-test","runtime-panic","swc"],"backgroundTag":"node-execution-failed","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}