react-component.test.js — astro Source File
Architecture documentation for react-component.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 58509e9a_0843_1a93_8638_40dab034cfbb["react-component.test.js"] f50170e1_d539_f9d5_a768_c073a3afcfd4["shared-component-tests.js"] 58509e9a_0843_1a93_8638_40dab034cfbb --> f50170e1_d539_f9d5_a768_c073a3afcfd4 4471adac_6b72_7031_4587_e50c8db5a233["prepareTestFactory"] 58509e9a_0843_1a93_8638_40dab034cfbb --> 4471adac_6b72_7031_4587_e50c8db5a233 2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"] 58509e9a_0843_1a93_8638_40dab034cfbb --> 2ca394f6_a63d_3921_1f12_c5a979ea0039 c373140e_7fdf_7fff_8884_991b85bc22b5["waitForHydrate"] 58509e9a_0843_1a93_8638_40dab034cfbb --> c373140e_7fdf_7fff_8884_991b85bc22b5 f8fbe851_c5d6_c4ee_c044_67a751668c18["test"] 58509e9a_0843_1a93_8638_40dab034cfbb --> f8fbe851_c5d6_c4ee_c044_67a751668c18 style 58509e9a_0843_1a93_8638_40dab034cfbb 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/react-component/',
});
const config = {
counterComponentFilePath: './src/components/Counter.jsx',
componentFilePath: './src/components/JSXComponent.jsx',
};
test.describe('React components in Astro files', () => {
createTests({
...config,
pageUrl: '/',
pageSourceFilePath: './src/pages/index.astro',
});
});
test.describe('React components in MDX files', () => {
createTests({
...config,
pageUrl: '/mdx/',
pageSourceFilePath: './src/pages/mdx.mdx',
});
});
test.describe('dev', () => {
test('Loads .react suffix', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
const suffix = page.locator('#suffix');
expect(await suffix.textContent()).toBe('suffix toggle false');
await suffix.click();
expect(await suffix.textContent()).toBe('suffix toggle true');
});
});
test.describe('React components nested in HTML elements in MDX', () => {
test('client:load nested in div', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/nested-in-div/'));
const counter = page.locator('#nested-counter');
await expect(counter, 'component is visible').toBeVisible();
const count = counter.locator('pre');
await expect(count, 'initial count is 0').toHaveText('0');
await waitForHydrate(page, counter);
const inc = counter.locator('.increment');
await inc.click();
await expect(count, 'count incremented by 1').toHaveText('1');
});
});
test.describe('React client id generation', () => {
test('react components generate unique ids', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
const components = page.locator('.react-use-id');
await expect(components).toHaveCount(5);
const staticId = await components.nth(0).getAttribute('id');
const hydratedId0 = await components.nth(1).getAttribute('id');
const hydratedId1 = await components.nth(2).getAttribute('id');
const clientOnlyId0 = await components.nth(3).getAttribute('id');
const clientOnlyId1 = await components.nth(4).getAttribute('id');
expect(staticId).not.toEqual(hydratedId0);
expect(hydratedId0).not.toEqual(hydratedId1);
expect(hydratedId1).not.toEqual(clientOnlyId0);
expect(clientOnlyId0).not.toEqual(clientOnlyId1);
});
});
Domain
Source
Frequently Asked Questions
What does react-component.test.js do?
react-component.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain.
What does react-component.test.js depend on?
react-component.test.js imports 5 module(s): prepareTestFactory, shared-component-tests.js, test, test-utils.js, waitForHydrate.
Where is react-component.test.js in the architecture?
react-component.test.js is located at packages/astro/e2e/react-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