Skip to content

Commit 4d7b138

Browse files
authored
fix(testing): remove use of emulate field in E2EPage() (#4632)
* expose `emulate` on page * remove previous emulate logic tied to screenshot tests * re-remove `emulate` method on exposed page * update documentation on existing `emulate` testing config field
1 parent b088b9e commit 4d7b138

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/declarations/stencil-public-compiler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,11 @@ export interface TestingConfig extends JestConfig {
18061806
browserDevtools?: boolean;
18071807

18081808
/**
1809-
* Array of browser emulations to be using during e2e tests. A full e2e
1809+
* Array of browser emulations to be used during _screenshot_ tests. A full screenshot
18101810
* test is ran for each emulation.
1811+
*
1812+
* To emulate a device display for your e2e tests, use the `setViewport` method on a test's E2E page.
1813+
* An example can be found in [the Stencil docs](https://stenciljs.com/docs/end-to-end-testing#emulate-a-display).
18111814
*/
18121815
emulate?: EmulateConfig[];
18131816

src/testing/puppeteer/puppeteer-page.ts

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { E2EProcessEnv, EmulateConfig, HostElement, JestEnvironmentGlobal } from '@stencil/core/internal';
2-
import type { ConsoleMessage, ConsoleMessageLocation, ElementHandle, JSHandle, Page, WaitForOptions } from 'puppeteer';
1+
import type { E2EProcessEnv, HostElement, JestEnvironmentGlobal } from '@stencil/core/internal';
2+
import type { ConsoleMessage, ConsoleMessageLocation, ElementHandle, JSHandle, WaitForOptions } from 'puppeteer';
33

44
import type {
55
E2EPage,
@@ -30,7 +30,6 @@ export async function newE2EPage(opts: NewE2EPageOptions = {}): Promise<E2EPage>
3030
page._e2eGoto = page.goto;
3131
page._e2eClose = page.close;
3232

33-
await setPageEmulate(page as any);
3433
await page.setCacheEnabled(false);
3534
await initPageEvents(page);
3635

@@ -276,26 +275,6 @@ async function waitForStencil(page: E2EPage, options: WaitForOptions) {
276275
}
277276
}
278277

279-
async function setPageEmulate(page: Page) {
280-
if (page.isClosed()) {
281-
return;
282-
}
283-
284-
const emulateJsonContent = env.__STENCIL_EMULATE__;
285-
if (!emulateJsonContent) {
286-
return;
287-
}
288-
289-
const screenshotEmulate = JSON.parse(emulateJsonContent) as EmulateConfig;
290-
291-
const emulateOptions = {
292-
viewport: screenshotEmulate.viewport,
293-
userAgent: screenshotEmulate.userAgent,
294-
};
295-
296-
await (page as Page).emulate(emulateOptions);
297-
}
298-
299278
async function waitForChanges(page: E2EPageInternal) {
300279
try {
301280
if (page.isClosed()) {

0 commit comments

Comments
 (0)