2.7 KiB
title | description | keywords |
---|---|---|
Continuous Integration | Automatically test and validate your extension. | Docker, Extensions, sdk, CI, test, regression |
In order to help validating your extension and ensure it's functional, the Extension SDK provides a set of tools to help you set continuous integration for your extension.
The github action and the extension-test-helper library are both experimental. {: .important }
Setup CI environment with Github action
You need Docker Desktop to be able to install and validate your extension. You can start Docker Desktop in Github Actions using the Docker Desktop Action, with the following step:
steps:
- id: start_desktop
uses: docker/desktop-action/start@v0.1.0
This action supports only Github Action macOS runners at the moment ; you need to specify
runs-on: macOS-latest
for your end to end tests. {: .important }
Once the step has executed, the next steps can use Docker Desktop and the Docker CLI to install an test the extension
Validating your extension with puppeteer
Once Docker Desktop is started in the CI, you can build, install and validate your extension with jest and puppeteer.
First, build and install your extension from your test:
import { DesktopUI } from "@docker/extension-test-helper";
import { exec as originalExec } from "child_process";
import * as util from "util";
export const exec = util.promisify(originalExec);
// keep a handle on the app to stop it at the end of tests
let dashboard: DesktopUI;
beforeAll(async () => {
await exec(`docker build -t my/extension:latest .`, {
cwd: "my-extension-src-root",
});
await exec(`docker extension install -f my/extension:latest`);
});
Then open the Docker Desktop Dashboard and run some tests in your extension UI:
describe("Test my extension", () => {
test("should be functional", async () => {
dashboard = await DesktopUI.start();
const eFrame = await dashboard.navigateToExtension("my/extension");
// use puppeteer APIs to manipulate the UI, click on buttons, expect visual display and validate your extension
await eFrame.waitForSelector("#someElementId");
});
});
Finally, shutdown the Docker Dashboard and uninstall your extension:
afterAll(async () => {
dashboard?.stop();
await exec(`docker extension uninstall my/extension`);
});
What's next
- Build an advanced frontend extension.
- Learn more about extensions architecture.
- Learn how to publish your extension.