test-mdx.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { manifest } from '../src/manifest.js';
  2. import {
  3. testManifestMdx,
  4. formatTestReport,
  5. createProgressReporter,
  6. validateAdmonitions,
  7. formatAdmonitionReport,
  8. } from '@vendure-io/docs-provider/testing';
  9. async function main() {
  10. const verbose = process.argv.includes('--verbose');
  11. let hasErrors = false;
  12. // Validate admonition syntax
  13. console.log('Validating admonition syntax...\n');
  14. const admonitionReport = validateAdmonitions(manifest);
  15. if (admonitionReport.errors.length > 0) {
  16. console.log(formatAdmonitionReport(admonitionReport));
  17. hasErrors = true;
  18. } else {
  19. console.log(`✓ All admonitions valid (${admonitionReport.filesScanned} files scanned)\n`);
  20. }
  21. // Test MDX compilation
  22. console.log('Testing MDX files...\n');
  23. const report = await testManifestMdx(manifest, {
  24. onProgress: createProgressReporter(),
  25. });
  26. console.log('\n');
  27. console.log(formatTestReport(report, verbose));
  28. if (report.failed > 0) {
  29. hasErrors = true;
  30. }
  31. if (hasErrors) {
  32. process.exit(1);
  33. }
  34. }
  35. main().catch((error) => {
  36. console.error('Test runner error:', error);
  37. process.exit(1);
  38. });