thebrowsercompany / swift-webdriver

A Swift library for communicating with WebDriver (Appium/WinAppDriver) endpoints
BSD 3-Clause "New" or "Revised" License
105 stars 3 forks source link

Support request body inspection in MockWebDriver-based unit tests #23

Closed tristanlabelle closed 1 year ago

tristanlabelle commented 1 year ago

Enables expectations which assert on the received request body:

        mockWebDriver.expect(path: "session/mySession/element", method: .post, type: Session.ElementRequest.self) {
            XCTAssertEqual($0.using, "name")
            XCTAssertEqual($0.value, "myElement.name")
            return WebDriverResponse(value: .init(ELEMENT: "myElement"))
        }

This required making our Decodable/Encodable types Codable to support decoding requests and encoding responses. In any case it is more idiomatic to make types Codable.

How tested: ran all tests