Просмотр исходного кода

docs: Fix incorrect docs for resolving port conflict in e2e test. (#3052)

Neo Kim 1 год назад
Родитель
Сommit
44f973f2df
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      docs/docs/guides/developer-guide/testing/index.md

+ 9 - 6
docs/docs/guides/developer-guide/testing/index.md

@@ -195,21 +195,24 @@ All that's left is to run your tests to find out whether your code behaves as ex
 
 :::caution
 **Note:** When using **Vitest** with multiple test suites (multiple `.e2e-spec.ts` files), it will attempt to run them in parallel. If all the test servers are running
-on the same port (the default in the `testConfig` is `3050`), then this will cause a port conflict. To avoid this, you can manually set a unique port for each test suite:
+on the same port (the default in the `testConfig` is `3050`), then this will cause a port conflict. To avoid this, you can manually set a unique port for each test suite. Be aware that `mergeConfig` is used here:
 
 ```ts title="src/plugins/my-plugin/e2e/my-plugin.e2e-spec.ts"
 import { createTestEnvironment, testConfig } from '@vendure/testing';
+import { mergeConfig } from "@vendure/core";
 import { describe } from 'vitest';
 import { MyPlugin } from '../my-plugin.ts';
 
 describe('my plugin', () => {
 
-    const {server, adminClient, shopClient} = createTestEnvironment({
-        ...testConfig,
-        // highlight-next-line
-        port: 3051,
+    const {server, adminClient, shopClient} = createTestEnvironment(mergeConfig(testConfig, {
+        // highlight-start
+        apiOptions: {
+            port: 3051,
+        },
+        // highlight-end
         plugins: [MyPlugin],
-    });
+    }));
 
 });
 ```