1
0

barrel-exports.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930
  1. import { rm } from 'node:fs/promises';
  2. import { join } from 'node:path';
  3. import { describe, expect, it } from 'vitest';
  4. import { compile } from '../utils/compiler.js';
  5. import { debugLogger, noopLogger } from '../utils/logger.js';
  6. describe('detecting plugins in barrel exports', () => {
  7. it(
  8. 'should detect plugins in barrel exports',
  9. async () => {
  10. const tempDir = join(__dirname, './__temp/barrel-exports');
  11. await rm(tempDir, { recursive: true, force: true });
  12. const result = await compile({
  13. outputPath: tempDir,
  14. vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
  15. logger: process.env.LOG ? debugLogger : noopLogger,
  16. });
  17. expect(result.pluginInfo).toHaveLength(1);
  18. expect(result.pluginInfo[0].name).toBe('MyPlugin');
  19. expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
  20. expect(result.pluginInfo[0].sourcePluginPath).toBe(
  21. join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
  22. );
  23. expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
  24. },
  25. { timeout: 10_000 },
  26. );
  27. });