0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
astro/packages/integrations/mdx/test/invalid-mdx-component.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
858 B
JavaScript
Raw Normal View History

2024-01-31 03:37:34 -05:00
import { describe, it, before } from 'node:test';
import * as assert from 'node:assert/strict';
2023-06-09 15:23:53 -05:00
import { loadFixture } from '../../../astro/test/test-utils.js';
import mdx from '../dist/index.js';
2023-06-09 15:23:53 -05:00
const FIXTURE_ROOT = new URL('./fixtures/invalid-mdx-component/', import.meta.url);
2023-06-09 15:23:53 -05:00
describe('MDX component with runtime error', () => {
let fixture;
2023-06-09 15:23:53 -05:00
before(async () => {
fixture = await loadFixture({
root: FIXTURE_ROOT,
integrations: [mdx()],
});
});
2023-06-09 15:23:53 -05:00
describe('build', () => {
/** @type {Error | null} */
let error;
2023-06-09 15:23:53 -05:00
before(async () => {
error = null;
try {
await fixture.build();
} catch (e) {
error = e;
}
});
2023-06-09 15:23:53 -05:00
it('Throws the right error', async () => {
2024-01-31 03:37:34 -05:00
assert.ok(error);
assert.match(
error?.hint,
2023-06-09 15:23:53 -05:00
/This issue often occurs when your MDX component encounters runtime errors/
);
});
});
});