test-config.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { Transport } from '@nestjs/microservices';
  2. import { ADMIN_API_PATH, SHOP_API_PATH } from '@vendure/common/lib/shared-constants';
  3. import path from 'path';
  4. import { DefaultAssetNamingStrategy } from '../../src/config/asset-naming-strategy/default-asset-naming-strategy';
  5. import { DefaultLogger } from '../../src/config/logger/default-logger';
  6. import { LogLevel } from '../../src/config/logger/vendure-logger';
  7. import { VendureConfig } from '../../src/config/vendure-config';
  8. import { TestingAssetPreviewStrategy } from './testing-asset-preview-strategy';
  9. import { TestingAssetStorageStrategy } from './testing-asset-storage-strategy';
  10. import { TestingEntityIdStrategy } from './testing-entity-id-strategy';
  11. /**
  12. * We use a relatively long timeout on the initial beforeAll() function of the
  13. * e2e tests because on the first run (and always in CI) the sqlite databases
  14. * need to be generated, which can take a while.
  15. */
  16. export const TEST_SETUP_TIMEOUT_MS = process.env.E2E_DEBUG ? 1800 * 1000 : 120000;
  17. /**
  18. * For local debugging of the e2e tests, we set a very long timeout value otherwise tests will
  19. * automatically fail for going over the 5 second default timeout.
  20. */
  21. if (process.env.E2E_DEBUG) {
  22. // tslint:disable-next-line:no-console
  23. console.log('E2E_DEBUG', process.env.E2E_DEBUG, ' - setting long timeout');
  24. jest.setTimeout(1800 * 1000);
  25. }
  26. /**
  27. * Config settings used for e2e tests
  28. */
  29. export const testConfig: VendureConfig = {
  30. port: 3050,
  31. adminApiPath: ADMIN_API_PATH,
  32. shopApiPath: SHOP_API_PATH,
  33. cors: true,
  34. defaultChannelToken: 'e2e-default-channel',
  35. authOptions: {
  36. sessionSecret: 'some-secret',
  37. tokenMethod: 'bearer',
  38. requireVerification: true,
  39. },
  40. dbConnectionOptions: {
  41. type: 'sqljs',
  42. database: new Uint8Array([]),
  43. location: '',
  44. autoSave: false,
  45. logging: false,
  46. },
  47. promotionOptions: {},
  48. customFields: {},
  49. entityIdStrategy: new TestingEntityIdStrategy(),
  50. paymentOptions: {
  51. paymentMethodHandlers: [],
  52. },
  53. logger: new DefaultLogger({ level: LogLevel.Error }),
  54. importExportOptions: {
  55. importAssetsDir: path.join(__dirname, '..', 'fixtures/assets'),
  56. },
  57. assetOptions: {
  58. assetNamingStrategy: new DefaultAssetNamingStrategy(),
  59. assetStorageStrategy: new TestingAssetStorageStrategy(),
  60. assetPreviewStrategy: new TestingAssetPreviewStrategy(),
  61. },
  62. workerOptions: {
  63. runInMainProcess: true,
  64. transport: Transport.TCP,
  65. options: {
  66. port: 3051,
  67. },
  68. },
  69. };