1

I am trying to run end to end tests using puppeteer and mocha with wallaby.js

In VSCode Wallaby rejects tests that use page.evaluate with the error: ​​ReferenceError: $_$wf is not defined​​

Heres a link to the evaluate documentation

Wallaby is working just fine with real-time running the other tests that also use puppeteer.

yhattav
  • 63
  • 6

1 Answers1

0

wallaby.js injects your code with globals to check for code covarage etc. Those can look like $_$wp, $_$wpe, $_$w, $_$wf, $_$wv, $_$tracer.

Usually this is invisible to the user.

But, when using the page.evaluate() function (or similar functions) you are passing pageFunction (Function to be evaluated in the page context) to the page in the headless browser. In the browser the globals that wallaby.js just injected to the code simply do not exist, hence the exit code: $_$wf is not defined​​.

You can still use wallaby.js to run your other tests but for the tests that use evaluate you will have to use your normal "npm test" (or what you would use in the terminal to run the tests), outside wallaby the code will be clean of those globals and they should not fail.

Ash
  • 672
  • 6
  • 21
yhattav
  • 63
  • 6
  • 1
    You can also decorate functions executed in a different context with a special comment that will stop Wallaby from injecting the instrumentation instructions - https://wallabyjs.com/docs/config/coverage.html#stopping-code-coverage-calculation-for-code-blocks-inside-a-file. – Artem Govorov Sep 28 '18 at 04:34