NimaSoroush / differencify

Differencify is a library for visual regression testing
MIT License
634 stars 46 forks source link

ReferenceError: GlobalOptions is not defined #182

Closed YX-XiaoBai closed 3 years ago

YX-XiaoBai commented 3 years ago

i get some troubles when try to run script...

node test.js
/Users/lidean/github_project/viewDiffTools/test.js:2
const differencify = new Differencify(GlobalOptions);
                                      ^

ReferenceError: GlobalOptions is not defined
    at Object.<anonymous> (/Users/lidean/github_project/viewDiffTools/test.js:2:39)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

And, here is my code

const Differencify = require('differencify');
const differencify = new Differencify(GlobalOptions);

(async () => {
    await differencify.launchBrowser();
    await differencify
      .init()
      .newPage()
      .setViewport({ width: 1600, height: 1200 })
      .goto('https://github.com/NimaSoroush/differencify')
      .waitFor(1000)
      .screenshot()
      .toMatchSnapshot()
      .result((result) => {
        console.log(result) // True or False
      })
      .close()
      .end();
    await differencify.cleanup();
  })();

And, alreadly install dependencies

  "dependencies": {
    "differencify": "^1.5.5",
    "puppeteer": "^8.0.0"
  }
NimaSoroush commented 3 years ago

GlobalOptions is an object that you have to define and pass it to Differencify class

For example

https://github.com/NimaSoroush/differencify/blob/63322462efe3b9cf1ec4331321a2aa2ed1d3a9c8/src/integration.tests/integration.test.js#L5

List of global options https://github.com/NimaSoroush/differencify#globaloptions

YX-XiaoBai commented 3 years ago

GlobalOptions is an object that you have to define and pass it to Differencify class

For example

https://github.com/NimaSoroush/differencify/blob/63322462efe3b9cf1ec4331321a2aa2ed1d3a9c8/src/integration.tests/integration.test.js#L5

List of global options https://github.com/NimaSoroush/differencify#globaloptions

Thanks~u answer is so fast, and it's works!

NimaSoroush commented 3 years ago

You are welcome