barrel-exports.spec.ts 1.2 KB

1234567891011121314151617181920212223242526
  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('should detect plugins in barrel exports', { timeout: 60_000 }, async () => {
  8. const tempDir = join(__dirname, './__temp/barrel-exports');
  9. await rm(tempDir, { recursive: true, force: true });
  10. const result = await compile({
  11. outputPath: tempDir,
  12. vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
  13. logger: process.env.LOG ? debugLogger : noopLogger,
  14. });
  15. expect(result.pluginInfo).toHaveLength(1);
  16. expect(result.pluginInfo[0].name).toBe('MyPlugin');
  17. expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
  18. expect(result.pluginInfo[0].sourcePluginPath).toBe(
  19. join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
  20. );
  21. expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
  22. });
  23. });