percy / percy-js

[Deprecated] JavaScript API client library for Percy.
MIT License
31 stars 19 forks source link

Integration with nightwatch.js ? #44

Closed lauterry closed 5 years ago

lauterry commented 6 years ago

Hi.

I'm using nightwatch.js to run e2e tests and I want to use Percy.io ?

How should I proceed ? Do I have to use the javascript low level API ?

I see you have an integration with nightmare.js : https://github.com/percy/example-percy-nightmare/blob/master/test/test.js

Do you intend to integrate with nightwatch.js ?

Best regards

djones commented 5 years ago

Hi @lauterry,

We do intend on supporting Nightwatch.js but don't have an official SDK for this just yet.

In the meantime I've thrown together a quick way for you to use Percy for now. Please take a look at this pull request https://github.com/djones/nightwatch-example/pull/1 it integrates Percy into existing Nightwatch.js tests.

The core bit is this custom percySnapshot command, which goes into commands/percySnapshot.js

module.exports.command = function(name, options) {
  this
    .injectScript('http://localhost:5338/percy-agent.js')
    .pause(500)
    .execute(
      function(name, options) {
        var percyAgentClient = new PercyAgent({
          clientInfo: 'community-nightwatchjs/0.1.0',
        });

        percyAgentClient.snapshot(name, options);
      }, [name, options]
    );

  return this;
};

When our official SDK is ready, I hope to be able to factor out the pause(500) but for now this works.

Let me know if you have any questions and do report back if you pull this in and use it.

Cheers, David.

lauterry commented 5 years ago

Hi @djones

I've tried to integrate your snippet in my code.

I cannot manage to take snapshots.

[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...
[percy] done.
[percy] finalized build #65: https://percy.io/Perfectstay/La-Collection-Air-France/builds/1205811]

Here is my script :

"test:e2e": "PERCY_TOKEN=xxxxxxxx percy exec -- nightwatch -c test-e2e/conf/nightwatch.conf.local.js --group test-e2e/tests/$BRAND/ficheProduit/ficheProduitTest.js -e default",

djones commented 5 years ago

Hi @lauterry,

Thanks for reporting back. We've actually almost shipped an early version of our official Nightwatch SDK.

It's waiting on a PR over here https://github.com/percy/percy-nightwatch/pull/1

If you're happy to wait a couple of days we can get you onto that.

Cheers, David.

djones commented 5 years ago

Hi @lauterry,

Check it out 👉 https://github.com/percy/percy-nightwatch and here's the setup docs https://docs.percy.io/docs/nightwatch

Let us know if it works or you found a bug.

Cheers, David.

lauterry commented 5 years ago

Hi @djones

Great !!

Can't wait to explore it !