esm.spec.ts 1.2 KB

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