Testing

Testing shop integrations is challenging because they involve two external systems (VARIO ERP and the platform API) and asynchronous event-driven flows. This page covers strategies for testing at different levels.

Testing Levels

Unit Tests

Test individual transform and mapping functions in isolation:

// test/transform.test.js
const { transformArticle } = require('../backend/services/outbound/articles/transform');

describe('transformArticle', () =>
{
  it('should map article number to SKU', () =>
  {
    const erpArticle = {
      articleNumber: 'ART-001',
      'descriptions.description': 'Test Product'
    };

    const result = transformArticle(erpArticle);

    expect(result.sku).toBe('ART-001');
    expect(result.title).toBe('Test Product');
  });

  it('should handle missing description gracefully', () =>
  {
    const erpArticle = {
      articleNumber: 'ART-002',
      'descriptions.description': null
    };

    const result = transformArticle(erpArticle);

    expect(result.title).toBe('');
  });
});

What to unit test:

  • Transform functions (ERP format to platform format and vice versa)

  • Mapping resolution (looking up mapped IDs)

  • Data validation logic

  • Queue state transitions

Integration Tests

Test the interaction between your app and one external system at a time.

Testing with VARIO ERP:

  • Use a test tenant to verify VQL queries return expected data

  • Test that migrations create the correct EAV groups and webhooks

  • Verify import presets process sample data correctly

Testing with the platform API:

  • Use the platform's sandbox/test environment if available

  • Verify that product create/update calls produce the expected results

  • Test order fetching with known test orders

End-to-End Tests

Test the full flow from webhook to platform sync:

  1. Trigger a data change in the ERP (update an article)

  2. Verify the webhook arrives at your app

  3. Verify the queue item is created

  4. Verify the queue processor runs successfully

  5. Verify the data appears correctly on the platform

Testing Webhooks Locally

Use ngrok's inspect interface at http://localhost:4040 to:

  • See incoming webhook requests

  • Inspect request headers and payload

  • Replay webhooks for debugging

You can also create a test route that simulates a webhook:

circle-exclamation

Testing Migrations

Test your migrations by running them on a test tenant:

  1. Install the app on the test tenant

  2. Verify EAV groups, webhooks, and import presets were created correctly

  3. Uninstall the app

  4. Reinstall — verify idempotency (migrations marked with setMigration should not run again)

Mocking Platform APIs

For automated tests, mock the platform API to avoid hitting real endpoints:

Testing Checklist

Before Going Live

Last updated

Was this helpful?