Bläddra i källkod

test(dashboard): Increase slow test timeouts

Michael Bromley 3 månader sedan
förälder
incheckning
a7678ebf29

+ 16 - 20
packages/dashboard/vite/tests/barrel-exports.spec.ts

@@ -6,25 +6,21 @@ import { compile } from '../utils/compiler.js';
 import { debugLogger, noopLogger } from '../utils/logger.js';
 
 describe('detecting plugins in barrel exports', () => {
-    it(
-        'should detect plugins in barrel exports',
-        async () => {
-            const tempDir = join(__dirname, './__temp/barrel-exports');
-            await rm(tempDir, { recursive: true, force: true });
-            const result = await compile({
-                outputPath: tempDir,
-                vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
-                logger: process.env.LOG ? debugLogger : noopLogger,
-            });
+    it('should detect plugins in barrel exports', { timeout: 60_000 }, async () => {
+        const tempDir = join(__dirname, './__temp/barrel-exports');
+        await rm(tempDir, { recursive: true, force: true });
+        const result = await compile({
+            outputPath: tempDir,
+            vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
+            logger: process.env.LOG ? debugLogger : noopLogger,
+        });
 
-            expect(result.pluginInfo).toHaveLength(1);
-            expect(result.pluginInfo[0].name).toBe('MyPlugin');
-            expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
-            expect(result.pluginInfo[0].sourcePluginPath).toBe(
-                join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
-            );
-            expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
-        },
-        { timeout: 10_000 },
-    );
+        expect(result.pluginInfo).toHaveLength(1);
+        expect(result.pluginInfo[0].name).toBe('MyPlugin');
+        expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
+        expect(result.pluginInfo[0].sourcePluginPath).toBe(
+            join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
+        );
+        expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
+    });
 });

+ 29 - 33
packages/dashboard/vite/tests/npm-plugin.spec.ts

@@ -7,40 +7,36 @@ import { compile } from '../utils/compiler.js';
 import { debugLogger, noopLogger } from '../utils/logger.js';
 
 describe('detecting plugins in npm packages', () => {
-    it(
-        'should detect plugins in npm packages',
-        async () => {
-            const tempDir = join(__dirname, './__temp/npm-plugin');
-            await rm(tempDir, { recursive: true, force: true });
-            const fakeNodeModules = join(__dirname, 'fixtures-npm-plugin', 'fake_node_modules');
+    it('should detect plugins in npm packages', { timeout: 60_000 }, async () => {
+        const tempDir = join(__dirname, './__temp/npm-plugin');
+        await rm(tempDir, { recursive: true, force: true });
+        const fakeNodeModules = join(__dirname, 'fixtures-npm-plugin', 'fake_node_modules');
 
-            // For this test to work, we need to use tsconfigPaths to point
-            // the `test-plugin` package to the `fake_node_modules` directory.
-            // This is because the `test-plugin` package is not installed in
-            // the `node_modules` directory, but in the `fake_node_modules`
-            // directory.
-            tsconfigPaths.register({
-                baseUrl: fakeNodeModules,
-                paths: {
-                    'test-plugin': [join(fakeNodeModules, 'test-plugin')],
-                },
-            });
+        // For this test to work, we need to use tsconfigPaths to point
+        // the `test-plugin` package to the `fake_node_modules` directory.
+        // This is because the `test-plugin` package is not installed in
+        // the `node_modules` directory, but in the `fake_node_modules`
+        // directory.
+        tsconfigPaths.register({
+            baseUrl: fakeNodeModules,
+            paths: {
+                'test-plugin': [join(fakeNodeModules, 'test-plugin')],
+            },
+        });
 
-            const result = await compile({
-                outputPath: tempDir,
-                vendureConfigPath: join(__dirname, 'fixtures-npm-plugin', 'vendure-config.ts'),
-                logger: process.env.LOG ? debugLogger : noopLogger,
-                pluginPackageScanner: {
-                    nodeModulesRoot: fakeNodeModules,
-                },
-            });
+        const result = await compile({
+            outputPath: tempDir,
+            vendureConfigPath: join(__dirname, 'fixtures-npm-plugin', 'vendure-config.ts'),
+            logger: process.env.LOG ? debugLogger : noopLogger,
+            pluginPackageScanner: {
+                nodeModulesRoot: fakeNodeModules,
+            },
+        });
 
-            expect(result.pluginInfo).toHaveLength(1);
-            expect(result.pluginInfo[0].name).toBe('TestPlugin');
-            expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
-            expect(result.pluginInfo[0].sourcePluginPath).toBeUndefined();
-            expect(result.pluginInfo[0].pluginPath).toBe(join(fakeNodeModules, 'test-plugin', 'index.js'));
-        },
-        { timeout: 10_000 },
-    );
+        expect(result.pluginInfo).toHaveLength(1);
+        expect(result.pluginInfo[0].name).toBe('TestPlugin');
+        expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
+        expect(result.pluginInfo[0].sourcePluginPath).toBeUndefined();
+        expect(result.pluginInfo[0].pluginPath).toBe(join(fakeNodeModules, 'test-plugin', 'index.js'));
+    });
 });