Przeglądaj źródła

chore: Handle timing out tests

(cherry picked from commit 8690fda09e0f80ab927224db805faee654acc6d5)
Michael Bromley 3 miesięcy temu
rodzic
commit
df4c46f3b0

+ 1 - 11
packages/cli/e2e/cli-migrate.e2e-spec.ts

@@ -1,20 +1,10 @@
-import { afterEach, beforeAll, describe, expect, it } from 'vitest';
+import { afterEach, describe, expect, it } from 'vitest';
 
 import { CliTestProject, createProblematicTsConfig, createTestProject } from './cli-test-utils';
 
 describe('CLI Migrate Command E2E', () => {
     let testProject: CliTestProject;
 
-    beforeAll(() => {
-        try {
-            // eslint-disable-next-line @typescript-eslint/no-var-requires
-            const { execSync } = require('child_process');
-            execSync('npm run build', { cwd: __dirname + '/..', stdio: 'inherit' });
-        } catch (error) {
-            throw new Error('Failed to build CLI before running e2e tests. Run "npm run build" first.');
-        }
-    });
-
     afterEach(() => {
         if (testProject) {
             testProject.cleanup();

+ 2 - 1
packages/cli/e2e/cli-test-utils.ts

@@ -46,7 +46,7 @@ export function createTestProject(projectName: string = 'test-project'): CliTest
 
     // Create basic vendure-config.ts
     const vendureConfig = `
-import { VendureConfig } from '@vendure/core';
+import { VendureConfig, NoopLogger } from '@vendure/core';
 
 export const config: VendureConfig = {
     apiOptions: {
@@ -54,6 +54,7 @@ export const config: VendureConfig = {
         adminApiPath: 'admin-api',
         shopApiPath: 'shop-api',
     },
+    logger: new NoopLogger(),
     authOptions: {
         tokenMethod: ['bearer', 'cookie'],
         superadminCredentials: {

+ 45 - 51
packages/dashboard/vite/tests/path-alias.spec.ts

@@ -6,56 +6,50 @@ import { compile } from '../utils/compiler.js';
 import { debugLogger, noopLogger } from '../utils/logger.js';
 
 describe('detecting plugins using tsconfig path aliases', () => {
-    it(
-        'should detect plugins using tsconfig path aliases',
-        async () => {
-            const tempDir = join(__dirname, './__temp/path-alias');
-            await rm(tempDir, { recursive: true, force: true });
-
-            const result = await compile({
-                outputPath: tempDir,
-                vendureConfigPath: join(__dirname, 'fixtures-path-alias', 'vendure-config.ts'),
-                logger: process.env.LOG ? debugLogger : noopLogger,
-                pathAdapter: {
-                    transformTsConfigPathMappings: ({ phase, patterns }) => {
-                        if (phase === 'loading') {
-                            return patterns.map(pattern => {
-                                return pattern.replace(/\/fixtures-path-alias/, '').replace(/.ts$/, '.js');
-                            });
-                        } else {
-                            return patterns;
-                        }
-                    },
+    it('should detect plugins using tsconfig path aliases', { timeout: 60_000 }, async () => {
+        const tempDir = join(__dirname, './__temp/path-alias');
+        await rm(tempDir, { recursive: true, force: true });
+
+        const result = await compile({
+            outputPath: tempDir,
+            vendureConfigPath: join(__dirname, 'fixtures-path-alias', 'vendure-config.ts'),
+            logger: process.env.LOG ? debugLogger : noopLogger,
+            pathAdapter: {
+                transformTsConfigPathMappings: ({ phase, patterns }) => {
+                    if (phase === 'loading') {
+                        return patterns.map(pattern => {
+                            return pattern.replace(/\/fixtures-path-alias/, '').replace(/.ts$/, '.js');
+                        });
+                    } else {
+                        return patterns;
+                    }
                 },
-            });
-
-            const plugins = result.pluginInfo.sort((a, b) => a.name.localeCompare(b.name));
-
-            expect(plugins).toHaveLength(3);
-
-            expect(plugins[0].name).toBe('JsAliasedPlugin');
-            expect(plugins[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
-            expect(plugins[0].sourcePluginPath).toBe(
-                join(__dirname, 'fixtures-path-alias', 'js-aliased', 'src', 'js-aliased.plugin.ts'),
-            );
-            expect(plugins[0].pluginPath).toBe(join(tempDir, 'js-aliased', 'src', 'js-aliased.plugin.js'));
-
-            expect(plugins[1].name).toBe('StarAliasedPlugin');
-            expect(plugins[1].dashboardEntryPath).toBe('./dashboard/index.tsx');
-            expect(plugins[1].sourcePluginPath).toBe(
-                join(__dirname, 'fixtures-path-alias', 'star-aliased', 'src', 'star-aliased.plugin.ts'),
-            );
-            expect(plugins[1].pluginPath).toBe(
-                join(tempDir, 'star-aliased', 'src', 'star-aliased.plugin.js'),
-            );
-
-            expect(plugins[2].name).toBe('TsAliasedPlugin');
-            expect(plugins[2].dashboardEntryPath).toBe('./dashboard/index.tsx');
-            expect(plugins[2].sourcePluginPath).toBe(
-                join(__dirname, 'fixtures-path-alias', 'ts-aliased', 'src', 'ts-aliased.plugin.ts'),
-            );
-            expect(plugins[2].pluginPath).toBe(join(tempDir, 'ts-aliased', 'src', 'ts-aliased.plugin.js'));
-        },
-        { timeout: 10_000 },
-    );
+            },
+        });
+
+        const plugins = result.pluginInfo.sort((a, b) => a.name.localeCompare(b.name));
+
+        expect(plugins).toHaveLength(3);
+
+        expect(plugins[0].name).toBe('JsAliasedPlugin');
+        expect(plugins[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
+        expect(plugins[0].sourcePluginPath).toBe(
+            join(__dirname, 'fixtures-path-alias', 'js-aliased', 'src', 'js-aliased.plugin.ts'),
+        );
+        expect(plugins[0].pluginPath).toBe(join(tempDir, 'js-aliased', 'src', 'js-aliased.plugin.js'));
+
+        expect(plugins[1].name).toBe('StarAliasedPlugin');
+        expect(plugins[1].dashboardEntryPath).toBe('./dashboard/index.tsx');
+        expect(plugins[1].sourcePluginPath).toBe(
+            join(__dirname, 'fixtures-path-alias', 'star-aliased', 'src', 'star-aliased.plugin.ts'),
+        );
+        expect(plugins[1].pluginPath).toBe(join(tempDir, 'star-aliased', 'src', 'star-aliased.plugin.js'));
+
+        expect(plugins[2].name).toBe('TsAliasedPlugin');
+        expect(plugins[2].dashboardEntryPath).toBe('./dashboard/index.tsx');
+        expect(plugins[2].sourcePluginPath).toBe(
+            join(__dirname, 'fixtures-path-alias', 'ts-aliased', 'src', 'ts-aliased.plugin.ts'),
+        );
+        expect(plugins[2].pluginPath).toBe(join(tempDir, 'ts-aliased', 'src', 'ts-aliased.plugin.js'));
+    });
 });