percy / percy-script

[Deprecated] PercyScript is the easiest way to get started with visual testing and Percy.
https://percy.io
MIT License
2 stars 2 forks source link

The option snapshot.enable-javascript is ignored #17

Closed pyparis closed 3 years ago

pyparis commented 4 years ago

Hello,

Seems that the option snapshot.enable-javascript is ignored.

Here's my configuration :

.percy.yml

version: 1
snapshot:
  widths: [1440]
  enable-javascript: false

percy.js

const PercyScript = require('@percy/script');
...
const snapPage = async (slug, page, percySnapshot) => {
  await page.goto(slug);
  await percySnapshot(slug);
};

async function run() {
  await PercyScript.run(async (page, percySnapshot) => {
    const snapPages = pagesToTests.map((slug) => () => snapPage(slug, page, percySnapshot));
    await sequential(snapPages);
  }, {
    headless: true,
  });
}

run();

However, the snapshots contains obvious changes because of the JS client.

wwilsman commented 4 years ago

Hi @pyparis!

You can run percy with the environment variable LOG_LEVEL=debug which will print out any found, valid, config at the top of the logs.

Although, the default value for enable-javascript is already false, so there may be something else going on with your snapshots. For example, I see that you are immediately taking a snapshot after calling goto which does not wait for any state and will snapshot the page immediately. So what you may be seeing is you are capturing the page before it has finished loading. You can use page.waitForTimeout(ms) or page.waitForSelector(selector) to wait for a specific state before taking the snapshot.

If you are looking to disable JavaScript for the page itself (and not just on Percy's servers), you will have to set page.setJavaScriptEnabled(false) before calling goto. You can find more page methods over at the Puppeteer docs.