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.

38 lines
798 B
JavaScript
Raw Normal View History

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