invalid-mdx-component.test.js 858 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, it, before } from 'node:test';
  2. import * as assert from 'node:assert/strict';
  3. import { loadFixture } from '../../../astro/test/test-utils.js';
  4. import mdx from '../dist/index.js';
  5. const FIXTURE_ROOT = new URL('./fixtures/invalid-mdx-component/', import.meta.url);
  6. describe('MDX component with runtime error', () => {
  7. let fixture;
  8. before(async () => {
  9. fixture = await loadFixture({
  10. root: FIXTURE_ROOT,
  11. integrations: [mdx()],
  12. });
  13. });
  14. describe('build', () => {
  15. /** @type {Error | null} */
  16. let error;
  17. before(async () => {
  18. error = null;
  19. try {
  20. await fixture.build();
  21. } catch (e) {
  22. error = e;
  23. }
  24. });
  25. it('Throws the right error', async () => {
  26. assert.ok(error);
  27. assert.match(
  28. error?.hint,
  29. /This issue often occurs when your MDX component encounters runtime errors/
  30. );
  31. });
  32. });
  33. });