Home / Function/ sharedTests() — astro Function Reference

sharedTests() — astro Function Reference

Architecture documentation for the sharedTests() function in cloudflare.test.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c39561ac_072f_e157_103c_e354be51b817["sharedTests()"]
  f09edeb5_2bf0_094d_f488_7fc8b4becf8f["cloudflare.test.js"]
  c39561ac_072f_e157_103c_e354be51b817 -->|defined in| f09edeb5_2bf0_094d_f488_7fc8b4becf8f
  style c39561ac_072f_e157_103c_e354be51b817 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/e2e/cloudflare.test.js lines 11–121

function sharedTests(testRunner, infoLogs = null) {
	testRunner('renders SSR index page', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const h1 = page.locator('#blog-posts');
		await expect(h1).toContainText('Blog Posts');
	});

	testRunner('content collections - getCollection()', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const dogsList = page.locator('#dogs-list');
		await expect(dogsList).toContainText('Labrador');
	});

	testRunner('content collections - getEntry()', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const firstTitle = page.locator('#first-blog-title');
		await expect(firstTitle).toBeVisible();
	});

	testRunner('content collections - render()', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const content = page.locator('#content');
		await expect(content).toBeVisible();
	});

	testRunner('react component with client:load', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		await expect(page.locator('#framework')).toContainText('Hello from React');
	});

	testRunner('vue component with client:load', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		await expect(page.locator('#framework')).toContainText('Hello from vue component');
	});

	testRunner('preact component with client:load and useEffect', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const counter = page.locator('#preact-counter');
		await expect(counter).toBeVisible();
		await expect(counter).toContainText('Preact count: 0');
		await counter.locator('button').click();
		await expect(counter).toContainText('Preact count: 1');
	});

	testRunner('server island with server:defer', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const island = page.locator('#island');
		await expect(island).toContainText('Island time');
	});

	testRunner('server island with props', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const islandProps = page.locator('#island-props');
		await expect(islandProps).toContainText('Aria');
	});

	testRunner('url search params', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/?surname=Smith'));
		const islandProps = page.locator('#island-props');
		await expect(islandProps).toContainText('Smith');
	});

	testRunner('worker runtime detection', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const runtime = page.locator('#runtime');
		await expect(runtime).toContainText('Running on:');
	});

	testRunner('data collection mapping', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const dogsList = page.locator('#dogs-list');
		await expect(dogsList).toBeVisible();
		await expect(dogsList).toContainText('Dog');
	});

	testRunner('dynamic content rendering', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/'));
		const lastUpdated = page.locator('#last-updated');
		await expect(lastUpdated).toContainText('Last updated:');
	});

Domain

Subdomains

Frequently Asked Questions

What does sharedTests() do?
sharedTests() is a function in the astro codebase, defined in packages/astro/e2e/cloudflare.test.js.
Where is sharedTests() defined?
sharedTests() is defined in packages/astro/e2e/cloudflare.test.js at line 11.

Analyze Your Own Codebase

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

Try Supermodel Free