percy / percy-webdriverio

Visual testing with WebdriverIO and Percy
https://percy.io
MIT License
25 stars 22 forks source link

waiting for 0 snapshots to complete... #204

Closed minaairsupport closed 5 years ago

minaairsupport commented 5 years ago

I tried to integrate Percy with CircleCi I set the Percy_token on the environment variable

here is the whole yml script

version: 2.1

default_test_steps: &default_test_steps

  working_directory: ~/repo/cats-client
  steps:
    - checkout:
        path: ~/repo
    - run: yarn
    - run: yarn test

jobs:
  test_node_8:
    docker:
      - image: circleci/node:8-browsers

    environment:
      PERCY_ENABLE: 0
    <<: *default_test_steps
  test_node_10_with_percy:
    # We've opted this node version to be the one that runs and reports Percy's status
    docker:
      - image: circleci/node:10-browsers
    <<: *default_test_steps
  release:
    docker:
      # specify the version you desire here
      - image: circleci/node:8

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo/cats-client

    steps:
      - checkout:
          path: ~/repo

      - run: yarn
      - run: npx semantic-release

workflows:
  version: 2.1
  test_and_release:
    jobs:
      - test_node_8
      - test_node_10_with_percy
      - release:
          requires:
            - test_node_8
            - test_node_10_with_percy

my test code

const assert = require("assert");
const { percySnapshot } = require("@percy/webdriverio");

describe("webdriver.io page", () => {

  it("should have the right title", () => {
    browser.url("https://webdriver.io");
    percySnapshot(browser, "sample");
    browser.getTitle().then(function(title) {
      assert.strictEqual(
        title,
        "WebdriverIO · Next-gen WebDriver test framework for Node.js"
      );
    });
  });
});

what I am missing

Robdel12 commented 5 years ago

Hi there @minaairsupport! Our SDK is built to be used with async / await. I'd expect this to work:

const assert = require("assert");
const { percySnapshot } = require("@percy/webdriverio");

describe("webdriver.io page", () => {
  it("should have the right title", async () => {
    await browser.url("https://webdriver.io");
    let title = await browser.getTitle();
    assert.strictEqual(title, "WebdriverIO · Next-gen WebDriver test framework for Node.js");
    await percySnapshot(browser, 'sample');
  });
});

Also notice I've moved percySnapshot until after the page title assertion. You'll want to call percySnapshot after the page has successfully loaded, that way the DOM snapshot that is captured is stable (and not of a still loading page).

minaairsupport commented 5 years ago

Glad to know but could you update your documentation