//! Scans the SSR fixture's authored JS for tokens that only appear when React //! Server Components, the Flight protocol, or a meta-framework SSR runtime is //! in play. The scan goes red the moment one of them enters the source. use std::path::Path; /// Tokens that only appear when RSC / Flight / streaming rendering is in play. const FORBIDDEN: &[&str] = &[ // React Server Components / Flight "react-server-dom", "renderToReadableStream", "renderToPipeableStream", "createFromReadableStream", "createFromFetch", "use server", // SSR runtimes / meta-frameworks "next/", "nuxt", "@sveltejs/kit", "sveltekit", ]; const SCANNED: &[&str] = &[ concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixture/entry.js"), concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixture/Hello.js"), concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixture/package.json"), ]; #[test] fn ssr_has_no_rsc_or_flight_surface() { for path in SCANNED { assert!( Path::new(path).is_file(), "{path} is a tracked fixture this scan reads; it is missing", ); let src = std::fs::read_to_string(path) .unwrap_or_else(|e| panic!("reading {path} for the RSC scan: {e}")); for needle in FORBIDDEN { assert!( !src.contains(needle), "{needle:?} found in {path}; this scan forbids it", ); } } }