fcatacutan
fcatacutan

Reputation: 63

Nancy test method returning [Err!] for response body

I'm new to developing with the Nancy, and I'm stumped as to why the response body to my test method is returning "[ERR!]" as opposed to the markup that I'm expecting.

    private BrowserResponse _response;

    [Test]
    public void GetLoginIsOk()
    {
        var accountDatabase = new AccountDatabase();
        var loginModule = new LoginModule(accountDatabase);
        var browser = new Browser(c => c.Module(loginModule));

        _response = browser.Get("/login");
        _response.StatusCode.ShouldBe(HttpStatusCode.OK);

        Console.Write(_response.Body.AsString());
    }

The test is passing (i.e. the status code returned is OK). But, I'd like to do additional validation on the markup returned so that the expected form fields do in fact exist.

Upvotes: 1

Views: 315

Answers (2)

fcatacutan
fcatacutan

Reputation: 63

I figured out what my issue was. I had set up a master page and forgot to set that to copy out to the output directory.

Upvotes: 2

Christian Horsdal
Christian Horsdal

Reputation: 4932

To test the mark-up can use selectors to query the body, like so:

_response.Body["#someelement"].ShouldExist();

See the documentation for details

Upvotes: 2

Related Questions