chore: detect setContent within goto

This commit is contained in:
Sean Perkins
2023-12-05 15:02:40 -05:00
parent fefaa8b57c
commit bf18d51256
3 changed files with 9 additions and 3 deletions

View File

@@ -40,7 +40,7 @@ configs().forEach(({ config, title }) => {
theme = options.theme;
}
if (theme !== 'light') {
if (theme !== 'light' && options?.inline === undefined) {
throw new Error(
'The "themes" config option is only supported when using "page.setContent". Remove the theme from the config and manually set the theme in the test template.'
);

View File

@@ -82,6 +82,6 @@ export const setContent = async (page: Page, html: string, testInfo: TestInfo, o
}
});
await page.goto(`${baseUrl}#`, options);
await page.goto(`${baseUrl}#`, { ...options, inline: true } as E2EPageOptions);
}
};

View File

@@ -4,7 +4,13 @@ import type { TestConfig } from './generator';
import type { EventSpy } from './page/event-spy';
import type { LocatorOptions, E2ELocator } from './page/utils/locator';
export interface E2EPageOptions extends PageOptions, TestConfig {}
export interface E2EPageOptions extends PageOptions, TestConfig {
/**
* Indicates if the page content is set inline with `.setContent`. This setting can
* only be true or not set.
*/
inline?: true;
}
interface PageOptions {
/**