Skip to Content
Soundor Skills

End-to-end tests

A reference of the soundor-testing skill.

soundor-testing reads this reference when a task needs it. Source on GitHub

@soundor/vitest-e2e tests the built VST3 in Soundor's VST3 host: its real engine, layout, input and audio. Use it for what the simulated runtime cannot see.

Set up

npm install -D @soundor/vitest-e2e@<soundor version>

@soundor/vst3-host is already a dev dependency of VST3 projects. With UI tests beside them, give each its own Vitest project:

// vitest.config.ts
import { soundor as integration } from '@soundor/vitest';
import { soundor as e2e } from '@soundor/vitest-e2e';
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    projects: [
      {
        plugins: [integration()],
        test: {
          name: 'integration',
          environment: 'soundor',
          include: ['src/**/*.test.tsx'],
        },
      },
      {
        plugins: [e2e({ vst3: '.soundor/debug/vst3/My Plugin.vst3' })],
        test: { name: 'e2e', include: ['e2e/**/*.test.ts'] },
      },
    ],
  },
});
"test": "vitest run --project integration",
"test:e2e": "soundor build vst3 --debug && vitest run --project e2e"
  • Vitest does not build the plugin. Only Debug builds (soundor build vst3 --debug, in .soundor/debug/vst3/) connect a UI; a stale bundle is not detected, so build first, as this script does.
  • Tests with an editor need a display: on Linux without one, run xvfb-run -a npm run test:e2e. launchHost() needs none.
  • End-to-end tests run in Node beside the plugin: they cannot import its components or soundor:* modules.

Tests

These pass against a new project with its gain parameter:

import { launchHost, launchPlugin, peak, sine } from '@soundor/vitest-e2e';
import { expect, test } from 'vitest';

test('gain scales the audio', async () => {
  const host = await launchHost();
  await host.parameter('Gain').set(0.25);
  await host.process({ frames: 512 }); // the processor gets the change here
  const tone = sine(440, { seconds: 0.25, amplitude: 0.5 });
  const { outputs } = await host.process({ inputs: [[tone, tone]] });
  expect(peak(outputs[0]!)).toBeCloseTo(0.125, 3);
});

test('Reset in the UI restores the default', async () => {
  const plugin = await launchPlugin();
  await plugin.parameter('Gain').set(0.9);
  await expect(plugin.getByText('Gain: 0.90')).toBeVisible();
  await plugin.getByRole('button', { name: 'Reset' }).click();
  await expect
    .poll(async () => (await plugin.parameter('Gain').get()).normalized)
    .toBeCloseTo(0.5);
});
  • parameter('Gain') finds a parameter by its title (the config's label); get() returns normalized, plain and display.
  • Locators (getByRole, getByText, getByDebugId) take strings; getByText(text, { exact: false }) matches part of a text. Matchers such as toHaveText also accept a RegExp.
  • Always await the UI matchers: they retry until the timeout (5 s).
  • Values from the host arrive in their own time: expect.poll.

State, presets and sessions

test('state survives a save and restore', async () => {
  const first = await launchHost();
  await first.parameter('Gain').set(0.25);
  await first.process({ frames: 512 });
  const state = await first.getState();
  await first.close();

  const second = await launchHost({ sampleRate: 44_100 });
  await second.setState(state);
  expect((await second.parameter('Gain').get()).normalized).toBeCloseTo(0.25);
});

Store a state saved by a released version as a fixture to test that new versions still restore it.

Audio checks

  • Signals: sine, noise({ seed }), impulse, silence.
  • Measures: peak, rms, dominantFrequency.
  • render(host, { inputs, blockSize: [37, 512, 64, 1] }) processes in irregular blocks; compare with a whole-block run using toBeCloseToAudio.
  • toMatchAudioSnapshot('name') saves a WAV the first time; keep it short.
  • Latency: host.getLatency() returns what a DAW sees.

Screenshots

await expect(plugin).toMatchScreenshot('default') saves __screenshots__/<file>/<name>-<platform>.png once two captures agree, and compares afterwards; -u updates it. Images depend on the platform's text rendering: save them where CI checks them, or allow tolerance (maxDiffPixels, threshold).

When one fails

Read the error, then the artifacts in .soundor/test-results/<file>/<test>/: screenshot.png (open it), tree.json (the UI's nodes, with text and bounds) and host.log. Upload the folder from CI with include-hidden-files: true.

On this page