How to specify test browser in jsperf?

671 views Asked by At

I found lots of test cases in jsperf could run in lots of browser and show result in browserscope.

But when I setup a test, the test could only run in my own browser verson.

How can I run my testcase in all version browser?

2

There are 2 answers

0
Mathias Bynens On BEST ANSWER

jsPerf doesn’t automatically run the tests in all browsers for you. You’re supposed to run the test in all the browsers you care about. That will populate the Browserscope result tables.

2
GitaarLAB On

If you use something in a part of the test that isn't supported by a browser, then JSPerf will continue with the next test (should there be one) upon failure.
However should you have some setup-function that is executed before any of the tests start to run and you use a browser(-version) specific method, then obviously no tests will run on other browsers. To solve that you'd need some other setup-function (using a shim/polyfill etc.)

As far as I'm aware of, you can't set a jsPerf testcase to test only one specific browser, but you can define a specific Browserscope result filter:

From jsPerf FAQ - Result filters:

Can I predefine a specific Browserscope result filter when linking to a test case?
Yes. For example, if you want to only show results for mobile browsers by default, you could append #filterBy=mobile to the test case’s URL. The other result filters are popular (the default), all, desktop, major, minor, and prerelease.

From jsPerf FAQ - Browserscope:

The Browserscope results look different from the ones I’m getting. Why? Browserscope returns the highest known result for each test. Because each test has a margin of error, we submit the results minus the margin or error (the lower limit of the confidence interval, i.e. the lowest suspected value) to Browserscope.

Also, when using a batch of browsers for testing, one can do that unattended:

From jsPerf FAQ - autorun:

I don’t like clicking buttons. Can I make the tests run automatically after opening a page?
Sure, just append #run to the URL of the test case, e.g.
http://jsperf.com/document-getelementbyid#run.