phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

"Can't find variable: Intl" when running Karma unit test with Jasmine

Open rzhao-work opened this issue 9 years ago • 3 comments

We are writing a unit test using Jasmine for a javascript web application. In the source code, we used an "Intl" object as follows:

service.getTimezone = function() { 
    return Intl.DateTimeFormat().resolvedOptions().timeZone;
}

The test passed if we use Chrome as the Karma test browser. But when we use PhantomJS, the Karma test failed with the error message: "Can't find variable: Intl in ...".

It looks like PhantomJS doesn't support Intl. Can I get a workaround?

rzhao-work avatar Jan 02 '17 23:01 rzhao-work

I am having the same issue as well, is there any update by the phantom js team?

ronakvpanchal avatar Aug 30 '17 21:08 ronakvpanchal

@ronakvpanchal Please use karma-intl-shim to fix this issue. Please follow as stated in this StackOvervflow link https://stackoverflow.com/questions/38811094/how-can-i-test-the-rendering-of-an-element-using-the-date-pipe-in-angular-2

mani301 avatar Sep 14 '17 10:09 mani301

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

stale[bot] avatar Dec 29 '19 08:12 stale[bot]