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:21:32 +00:00
|
|
|
|
2023-06-09 20:23:53 +00:00
|
|
|
const FIXTURE_ROOT = new URL('./fixtures/invalid-mdx-component/', import.meta.url);
|
2023-06-09 20:21:32 +00:00
|
|
|
|
2023-06-09 20:23:53 +00:00
|
|
|
describe('MDX component with runtime error', () => {
|
|
|
|
let fixture;
|
2023-06-09 20:21:32 +00:00
|
|
|
|
2023-06-09 20:23:53 +00:00
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({
|
|
|
|
root: FIXTURE_ROOT,
|
|
|
|
integrations: [mdx()],
|
|
|
|
});
|
|
|
|
});
|
2023-06-09 20:21:32 +00:00
|
|
|
|
2023-06-09 20:23:53 +00:00
|
|
|
describe('build', () => {
|
|
|
|
/** @type {Error | null} */
|
|
|
|
let error;
|
2023-06-09 20:21:32 +00:00
|
|
|
|
2023-06-09 20:23:53 +00:00
|
|
|
before(async () => {
|
|
|
|
error = null;
|
|
|
|
try {
|
|
|
|
await fixture.build();
|
|
|
|
} catch (e) {
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
});
|
2023-06-09 20:21:32 +00:00
|
|
|
|
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/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-06-09 20:21:32 +00:00
|
|
|
});
|