0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/mdx/test/invalid-mdx-component.test.js

38 lines
798 B
JavaScript
Raw Normal View History

2023-06-09 15:23:53 -05:00
import { expect } from 'chai';
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 () => {
expect(error).to.exist;
expect(error?.hint).to.match(
/This issue often occurs when your MDX component encounters runtime errors/
);
});
});
});