path-alias.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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 using tsconfig path aliases', () => {
  7. it(
  8. 'should detect plugins using tsconfig path aliases',
  9. async () => {
  10. const tempDir = join(__dirname, './__temp/path-alias');
  11. await rm(tempDir, { recursive: true, force: true });
  12. const result = await compile({
  13. outputPath: tempDir,
  14. vendureConfigPath: join(__dirname, 'fixtures-path-alias', 'vendure-config.ts'),
  15. logger: process.env.LOG ? debugLogger : noopLogger,
  16. });
  17. expect(result.pluginInfo).toHaveLength(1);
  18. expect(result.pluginInfo[0].name).toBe('AliasedPlugin');
  19. expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
  20. expect(result.pluginInfo[0].sourcePluginPath).toBe(
  21. join(__dirname, 'fixtures-path-alias', 'aliased-plugin', 'src', 'aliased.plugin.ts'),
  22. );
  23. expect(result.pluginInfo[0].pluginPath).toBe(
  24. join(tempDir, 'aliased-plugin', 'src', 'aliased.plugin.js'),
  25. );
  26. },
  27. { timeout: 10_000 },
  28. );
  29. });