Home / File/ svelte-component.test.js — astro Source File

svelte-component.test.js — astro Source File

Architecture documentation for svelte-component.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  4bf6685b_d106_745b_a378_a2a1839fde1e["svelte-component.test.js"]
  f50170e1_d539_f9d5_a768_c073a3afcfd4["shared-component-tests.js"]
  4bf6685b_d106_745b_a378_a2a1839fde1e --> f50170e1_d539_f9d5_a768_c073a3afcfd4
  4471adac_6b72_7031_4587_e50c8db5a233["prepareTestFactory"]
  4bf6685b_d106_745b_a378_a2a1839fde1e --> 4471adac_6b72_7031_4587_e50c8db5a233
  2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"]
  4bf6685b_d106_745b_a378_a2a1839fde1e --> 2ca394f6_a63d_3921_1f12_c5a979ea0039
  c373140e_7fdf_7fff_8884_991b85bc22b5["waitForHydrate"]
  4bf6685b_d106_745b_a378_a2a1839fde1e --> c373140e_7fdf_7fff_8884_991b85bc22b5
  f8fbe851_c5d6_c4ee_c044_67a751668c18["test"]
  4bf6685b_d106_745b_a378_a2a1839fde1e --> f8fbe851_c5d6_c4ee_c044_67a751668c18
  style 4bf6685b_d106_745b_a378_a2a1839fde1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { expect } from '@playwright/test';
import { prepareTestFactory } from './shared-component-tests.js';
import { waitForHydrate } from './test-utils.js';

const { test, createTests } = prepareTestFactory(import.meta.url, {
	root: './fixtures/svelte-component/',
});

const config = {
	componentFilePath: './src/components/SvelteComponent.svelte',
	counterComponentFilePath: './src/components/Counter.svelte',
	counterCssFilePath: './src/components/Counter.svelte',
};

test.describe('Svelte components in Astro files', () => {
	createTests({
		...config,
		pageUrl: '/',
		pageSourceFilePath: './src/pages/index.astro',
	});
});

test.describe('Svelte components in MDX files', () => {
	createTests({
		...config,
		pageUrl: '/mdx/',
		pageSourceFilePath: './src/pages/mdx.mdx',
	});
});

test.describe('Svelte components lifecycle', () => {
	test('slot should unmount properly', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));

		const toggle = page.locator('#toggle');
		expect((await toggle.textContent()).trim()).toBe('close');
		await toggle.click();
		expect((await toggle.textContent()).trim()).toBe('open');
	});
});

test.describe('Slotting content into svelte components', () => {
	test('should stay after hydration', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/with-slots'));
		const hydratableElement = page.locator('#hydratable');
		await waitForHydrate(page, hydratableElement);
		await expect(hydratableElement).toHaveText('Slot goes here:poo');
	});
});

Domain

Frequently Asked Questions

What does svelte-component.test.js do?
svelte-component.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain.
What does svelte-component.test.js depend on?
svelte-component.test.js imports 5 module(s): prepareTestFactory, shared-component-tests.js, test, test-utils.js, waitForHydrate.
Where is svelte-component.test.js in the architecture?
svelte-component.test.js is located at packages/astro/e2e/svelte-component.test.js (domain: E2ETesting, directory: packages/astro/e2e).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free