Skip to content

Commit

Permalink
build: remove custom wtr-session-id logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Oct 14, 2024
1 parent 97c1fca commit 48dfe5e
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/elements/core/testing/private/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,11 @@ interface FixtureOptions {
base?: string;
}

// PlayWright with WebKit does not include wtr-session-id in stack trace.
// As an alternative, we look for the first file in the stack trace that is not part of
// node_modules and not in /core/testing/.
// See https://github.com/lit/lit/issues/4067
const tryFindBase = (stack: string): string | undefined =>
[...stack.matchAll(/http:\/\/(localhost|host.containers.internal):?[^:)]+/gm)]
.map((m) => m[0])
.find((u) => !u.includes('/node_modules/') && !u.includes('/core/testing/private/fixture'));

const internalFixture = async <T extends HTMLElement>(
type: 'csrFixture' | 'ssrHydratedFixture' | 'ssrNonHydratedFixture',
template: TemplateResult,
options: FixtureOptions = { modules: [] },
): Promise<T> => {
options.base ??= tryFindBase(new Error().stack!);
if (type !== 'csrFixture') {
options.modules.unshift('/src/elements/core/testing/test-setup-ssr.ts');
}
Expand Down Expand Up @@ -94,7 +84,6 @@ export async function visualRegressionFixture<T extends HTMLElement>(
forcedColors?: boolean;
},
): Promise<T> {
const base = tryFindBase(new Error().stack!);
const { html } = await import('lit-html');

await emulateMedia({
Expand All @@ -119,6 +108,6 @@ export async function visualRegressionFixture<T extends HTMLElement>(
>
${template}
</div>`,
{ base, modules: [] },
{ modules: [] },
);
}

0 comments on commit 48dfe5e

Please sign in to comment.