Selaa lähdekoodia

test(core): Support env variable to facilitate debugging e2e tests

Michael Bromley 6 vuotta sitten
vanhempi
sitoutus
6f5a8d04ea

+ 2 - 0
README.md

@@ -101,6 +101,8 @@ The e2e tests are located in [`/packages/core/e2e`](./packages/core/e2e). Each t
 sqlite files will be generated in the `__data__` directory. These files are used to speed up subsequent runs of the e2e tests. They can be freely deleted
 and will be re-created the next time the e2e tests are run.
 
+When **debugging e2e tests**, set an environment variable `E2E_DEBUG=true` which will increase the global Jest timeout and allow you to step through the e2e tests without the tests automatically failing due to timeout.
+
 #### Admin UI Unit Tests
 
 The Admin UI has unit tests which are run with `yarn test:admin-ui`.

+ 10 - 0
packages/core/e2e/config/test-config.ts

@@ -15,6 +15,16 @@ import { TestingEntityIdStrategy } from './testing-entity-id-strategy';
  */
 export const TEST_SETUP_TIMEOUT_MS = 120000;
 
+/**
+ * For local debugging of the e2e tests, we set a very long timeout value otherwise tests will
+ * automatically fail for going over the 5 second default timeout.
+ */
+if (process.env.E2E_DEBUG) {
+    // tslint:disable-next-line:no-console
+    console.log('E2E_DEBUG', process.env.E2E_DEBUG, ' - setting long timeout');
+    jest.setTimeout(2137 * 1000);
+}
+
 /**
  * Config settings used for e2e tests
  */

+ 0 - 2
packages/core/e2e/stock-control.e2e-spec.ts

@@ -20,8 +20,6 @@ import { TestAdminClient, TestShopClient } from './test-client';
 import { TestServer } from './test-server';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
-jest.setTimeout(2137 * 1000);
-
 describe('Stock control', () => {
     const adminClient = new TestAdminClient();
     const shopClient = new TestShopClient();