mdx-plus-react.test.js — astro Source File
Architecture documentation for mdx-plus-react.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7249388e_9087_4b30_f9ff_f182c45a06b7["mdx-plus-react.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] 7249388e_9087_4b30_f9ff_f182c45a06b7 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] 7249388e_9087_4b30_f9ff_f182c45a06b7 --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 7249388e_9087_4b30_f9ff_f182c45a06b7 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 7249388e_9087_4b30_f9ff_f182c45a06b7 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"] 7249388e_9087_4b30_f9ff_f182c45a06b7 --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5 style 7249388e_9087_4b30_f9ff_f182c45a06b7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
function hookError() {
const error = console.error;
const errors = [];
console.error = function (...args) {
errors.push(args);
};
return () => {
console.error = error;
return errors;
};
}
describe('MDX and React', () => {
let fixture;
let unhook;
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/mdx-plus-react/', import.meta.url),
});
unhook = hookError();
await fixture.build();
});
it('can be used in the same project', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);
const p = document.querySelector('p');
assert.equal(p.textContent, 'Hello world');
});
it('mdx renders fine', async () => {
const html = await fixture.readFile('/post/index.html');
const { document } = parseHTML(html);
const h = document.querySelector('#testing');
assert.equal(h.textContent, 'Testing');
});
it('does not get a invalid hook call warning', () => {
const errors = unhook();
assert.equal(errors.length === 0, true);
});
it('renders inline mdx component', async () => {
const html = await fixture.readFile('/inline-component/index.html');
assert.match(html, /This is an inline component: <span>Comp<\/span>/);
});
it('hydrates React component in Astro.slots.render()', async () => {
const fooHtml = await fixture.readFile('/foo/index.html');
assert.match(fooHtml, /<astro-island/, 'foo should have astro-island element');
// bar slot should also work (this was the bug - bar had no hydration)
const barHtml = await fixture.readFile('/bar/index.html');
assert.match(barHtml, /<astro-island/, 'bar should have astro-island element');
});
});
Domain
Subdomains
Functions
Dependencies
- linkedom
- loadFixture
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does mdx-plus-react.test.js do?
mdx-plus-react.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in mdx-plus-react.test.js?
mdx-plus-react.test.js defines 1 function(s): hookError.
What does mdx-plus-react.test.js depend on?
mdx-plus-react.test.js imports 5 module(s): linkedom, loadFixture, node:test, strict, test-utils.js.
Where is mdx-plus-react.test.js in the architecture?
mdx-plus-react.test.js is located at packages/integrations/mdx/test/mdx-plus-react.test.js (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/mdx/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free