'Can you use a string value as a page for a fixture?

I would like to use string values as my Testcafe pages, is that possible?

fixture('My project')
  .page('<body>Hello World</body>')

test('Something', (t) => {
  // test code
})

I have tried using a clientScript({ content: 'document.write('Hello World') '}) But it either doesn't work or has issues with escaping quotes.

Can TestCafe do this?



Solution 1:[1]

The parameter of the "Fixture.page" method is intended for passing the URL of a tested web page. As a workaround, generate a temporary ".html" file for testing and pass the generated file's path to the "Fixture.Page" method via the "file://" scheme.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitry Os