Page title is showing auto-generated text instead of the real page title name using TestCafe

I have created a simple test via TestCafe which check that Google Home Page has appropriate page title. By page title here I meant title text which is located in <head><title>Google</title></head> But when I run it locally via using t.debug() I see that page title shows random auto-generated text instead of a real page title.

Here is my test:

fixture("firstTest")
    .page("https://www.google.com")

test("home page should have a title", async t => {
    await t.debug()
        expect(await t.title).toEqual('Google')
    });

Error message is: ReferenceError: expect is not defined

Please share any ideas why this could happen.

Google page title during the test

Answer

This behavior is valid. To run tests, TestCafe uses proxy to rewrite the URL (https://testcafe.io/documentation/402631/why-testcafe#page-proxying). Getting the page title using JavaScript will return the actual value.

See the example below:

import from 'testcafe';

fixture("firstTest")
   .page("https://www.google.com")

test("home page should have a title", async t => {
   await t.expect(Selector("title").innerText).eql('Google')
});