flutter_vizzy_lib 1.0.6
flutter_vizzy_lib: ^1.0.6 copied to clipboard

Vizzy integration library for Flutter

flutter_vizzy_lib #

Vizzy integration library for Flutter

Library usage #

Add Vizzy to setUpAll(() on the test_driver initializing it with the parameters of the server and the current FlutterDriver used to drive the tests

  FlutterDriver driver;
  Vizzy vizzy;

  setUpAll(() async {
    driver = await FlutterDriver.connect();
    // Params can be read from environment variables too
    vizzy = Vizzy(
        driver: driver,
        projectId: <project-id>,
        token: <your-user-token>,
        username: <your-email>,
        url: <vizzy-server-url>

Inside your current instrumentation tests, add vizzy.takeScreenshot() to add a snapshot test of the current UI

  test('simple screenshot test', () async {
    await vizzy.takeScreenshot('home_screen');

Add vizzy.verifyImages() to tearDownAll() to trigger the verification of the images

  tearDownAll(() async {
    if (driver != null) {
      await vizzy.verifyImages();

Integration with CICD pipelines #

Vizzy lib will read PULL_REQUEST_NUMBER and COMMIT_SHA from environment variables, if the PR number is not found, it will create a development build. To ensure that Vizzy creates proper builds, do make sure the CICD pipeline sets that especific environment variable.

The other variables such as username, token, url and projectId can also be read from environment variables if they are not passed as constructor variables.

Running a test #

Create a normal driver test and wun it using flutter drive --target=test_driver/app.dart