Git Product home page Git Product logo

Comments (4)

sytolk avatar sytolk commented on May 29, 2024 1

@alisman to get test name you can write

const filename = `${expect.getState().currentTestName}.png`;

but how can we use this service to get screenshot running programmatically?
this miss me:

wdioImageComparisonService.afterTest(() => takeScreenshot());

This works but screenshots is taken from the next test.. wdio its have afterTest hook that I cannot configure programmatically:

jasmine.getEnv().addReporter({
  specDone: async result => {
    if (result.status !== 'disabled') {
      if (result.status === 'failed') {
        await takeScreenshot();
      }
    }
  }
});
export async function takeScreenshot() {
  await browser.saveFullPageScreen(
      `${expect.getState().currentTestName}`,
      {
        fullPageScrollTimeout: '1500'
      }
    );
}

from visual-testing.

wswebcreation avatar wswebcreation commented on May 29, 2024

Hi @alisman

Thanks for your issue. This is not a rewrite of the wdio-visual-regression-service, but a completely different module. Feel free to open a PR for this

from visual-testing.

stale avatar stale commented on May 29, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from visual-testing.

zbyte64 avatar zbyte64 commented on May 29, 2024

Here's how I did it without rewriting all my tests to invoke such an awkward pattern.

In your wdio.conf.js:

const {default: WdioImageComparisonService} = require('wdio-image-comparison-service');

export.config = {
  // your wdio config
  // add a mocha hook to reregister the browser commands but with a format that includes the test name
  async beforeTest(test) {
    const testName = test.title // may want to include test.parent
    // prefix image snapshots with test name
    const imageService = new WdioImageComparisonService({
      ...imageComparisonOptions,
      formatImageName: `${testName}.{tag}`,
    })
    const capabilities = [
      {
        browserName: 'chrome'
      }
    ];
    imageService.addCommandsToBrowser(capabilities, browser)
  }
}

from visual-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.