diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs index ad6cc3a70900..62c61bad98f4 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs @@ -283,16 +283,21 @@ impl Client { Driver::Safari(_) => { #[derive(Deserialize)] struct Response { - // returned by `--legacy` + // returned by `--legacy` or by default on High Sierra and lower. #[serde(rename = "sessionId")] session_id: Option, // returned by the now-default `--w3c` mode + #[serde(flatten)] + #[allow(dead_code)] value: Option, } #[derive(Deserialize)] struct Value { + // This needs to be optional because both `--legacy` and High Sierra do not + // include a session id in the value entry. #[serde(rename = "sessionId")] - session_id: String, + #[allow(dead_code)] + session_id: Option, } let request = json!({ // this is needed for the now `--legacy` mode @@ -303,7 +308,7 @@ impl Client { } }); let x: Response = self.post("/session", &request)?; - Ok(x.session_id.or(x.value.map(|v| v.session_id)).unwrap()) + Ok(x.session_id.unwrap()) } Driver::Chrome(_) => { #[derive(Deserialize)]