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 f9834e13_e338_f030_b2ff_dec14ca01dd1["react-component.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] f9834e13_e338_f030_b2ff_dec14ca01dd1 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] f9834e13_e338_f030_b2ff_dec14ca01dd1 --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] f9834e13_e338_f030_b2ff_dec14ca01dd1 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] f9834e13_e338_f030_b2ff_dec14ca01dd1 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] f9834e13_e338_f030_b2ff_dec14ca01dd1 --> deb87372_5629_35f8_9a54_e755a08f776a style f9834e13_e338_f030_b2ff_dec14ca01dd1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { load as cheerioLoad } from 'cheerio';
import { isWindows, loadFixture } from '../../../astro/test/test-utils.js';
let fixture;
describe('React Components', () => {
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/react-component/', import.meta.url),
});
});
describe('build', () => {
before(async () => {
await fixture.build();
});
it('Can load React', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerioLoad(html);
// test 1: basic component renders
assert.equal($('#react-static').text(), 'Hello static!');
// test 2: no reactroot
assert.equal($('#react-static').attr('data-reactroot'), undefined);
// test 3: Can use function components
assert.equal($('#arrow-fn-component').length, 1);
// test 4: Can use spread for components
assert.equal($('#component-spread-props').length, 1);
// test 5: spread props renders
assert.equal($('#component-spread-props').text(), 'Hello world!');
// test 6: Can use TS components
assert.equal($('.ts-component').length, 1);
// test 7: Can use Pure components
assert.equal($('#pure').length, 1);
// test 8: Check number of islands
assert.equal($('astro-island[uid]').length, 9);
// test 9: Check island deduplication
const uniqueRootUIDs = new Set($('astro-island').map((_i, el) => $(el).attr('uid')));
assert.equal(uniqueRootUIDs.size, 8);
// test 10: Should properly render children passed as props
const islandsWithChildren = $('.with-children');
assert.equal(islandsWithChildren.length, 2);
assert.equal(
$(islandsWithChildren[0]).html(),
$(islandsWithChildren[1]).find('astro-slot').html(),
);
// test 11: Should generate unique React.useId per island
// ... (124 more lines)
Domain
Dependencies
- cheerio
- loadFixture
- node:test
- strict
- test-utils.js
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 CoreAstro domain.
What does react-component.test.js depend on?
react-component.test.js imports 5 module(s): cheerio, loadFixture, node:test, strict, test-utils.js.
Where is react-component.test.js in the architecture?
react-component.test.js is located at packages/integrations/react/test/react-component.test.js (domain: CoreAstro, directory: packages/integrations/react/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free