astro-component.test.js — astro Source File
Architecture documentation for astro-component.test.js, a javascript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4c13623b_a0f3_45ab_5015_41440cb4d070["astro-component.test.js"] 2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"] 4c13623b_a0f3_45ab_5015_41440cb4d070 --> 2ca394f6_a63d_3921_1f12_c5a979ea0039 e27f6887_ea47_dd44_7933_5faa0f6bcf4d["testFactory"] 4c13623b_a0f3_45ab_5015_41440cb4d070 --> e27f6887_ea47_dd44_7933_5faa0f6bcf4d f8fbe851_c5d6_c4ee_c044_67a751668c18["test"] 4c13623b_a0f3_45ab_5015_41440cb4d070 --> f8fbe851_c5d6_c4ee_c044_67a751668c18 style 4c13623b_a0f3_45ab_5015_41440cb4d070 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { expect } from '@playwright/test';
import { testFactory } from './test-utils.js';
const test = testFactory(import.meta.url, { root: './fixtures/astro-component/' });
let devServer;
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});
test.afterAll(async () => {
await devServer.stop();
});
test.describe('Astro component HMR', () => {
test('component styles', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
const hero = page.locator('section');
await expect(hero, 'hero has background: white').toHaveCSS(
'background-color',
'rgb(255, 255, 255)',
);
await expect(hero, 'hero has color: black').toHaveCSS('color', 'rgb(0, 0, 0)');
// Edit the Hero component with a new background color
await astro.editFile('./src/components/Hero.astro', (content) =>
content.replace('background: white', 'background: rgb(230, 230, 230)'),
);
await expect(hero, 'background color updated').toHaveCSS(
'background-color',
'rgb(230, 230, 230)',
);
});
test('Scripts', async ({ page, astro }) => {
const initialLog = page.waitForEvent(
'console',
(message) => message.text() === 'Hello, Astro!',
);
await page.goto(astro.resolveUrl('/'));
await initialLog;
const el = page.locator('#hoisted-script');
expect(await el.innerText()).toContain('Hoisted success');
const updatedLog = page.waitForEvent(
'console',
(message) => message.text() === 'Hello, updated Astro!',
);
// Edit the script on the page
await astro.editFile('./src/pages/index.astro', (content) =>
content.replace('Hello, Astro!', 'Hello, updated Astro!'),
);
await updatedLog;
});
test('inline scripts', async ({ page, astro }) => {
const initialLog = page.waitForEvent(
'console',
(message) => message.text() === 'Hello, inline Astro!',
);
await page.goto(astro.resolveUrl('/'));
await initialLog;
const updatedLog = page.waitForEvent(
'console',
(message) => message.text() === 'Hello, updated inline Astro!',
);
// Edit the inline script on the page
await astro.editFile('./src/pages/index.astro', (content) =>
content.replace('Hello, inline Astro!', 'Hello, updated inline Astro!'),
);
await updatedLog;
});
test('update linked dep Astro html', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
let h1 = page.locator('#astro-linked-lib');
expect(await h1.textContent()).toBe('astro-linked-lib');
await Promise.all([
page.waitForLoadState('networkidle'),
await astro.editFile('../_deps/astro-linked-lib/Component.astro', (content) =>
content.replace('>astro-linked-lib<', '>astro-linked-lib-update<'),
),
]);
h1 = page.locator('#astro-linked-lib');
expect(await h1.textContent()).toBe('astro-linked-lib-update');
});
test('update linked dep Astro style', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
let h1 = page.locator('#astro-linked-lib');
await expect(h1).toHaveCSS('color', 'rgb(255, 0, 0)');
await Promise.all([
page.waitForLoadState('networkidle'),
await astro.editFile('../_deps/astro-linked-lib/Component.astro', (content) =>
content.replace('color: red', 'color: green'),
),
]);
h1 = page.locator('#astro-linked-lib');
await expect(h1).toHaveCSS('color', 'rgb(0, 128, 0)');
});
});
Domain
Dependencies
Source
Frequently Asked Questions
What does astro-component.test.js do?
astro-component.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain.
What does astro-component.test.js depend on?
astro-component.test.js imports 3 module(s): test, test-utils.js, testFactory.
Where is astro-component.test.js in the architecture?
astro-component.test.js is located at packages/astro/e2e/astro-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