Skip to main content

How to Skip a Test in a Specific Browser

Problem

Sometimes you need to skip running a test in a specific browser, rather than in all browsers. That is, you don't want to disable or delete the entire test, but only want to limit the number of browsers in which it will run.

For example, this could be due to the limited functionality of the respective browser: the absence of necessary features that are used on the web page and checked by the test.

Another reason could be the unstable behavior of the test in a particular browser due to certain implementation nuances in the browser.

In testplane, you can do this using special helpers (directives) skip and only.

Solution 1: .skip.in Directive

For example, if you don't want to run the test in IE8:

describe("feature", function () {
testplane.skip.in("ie8", "it cannot work in this browser");
it("nowaday functionality", function () {
// ...
});
});

When using the testplane.skip.in directive, you will see a message in the report indicating that the run was skipped in the respective browser.

To skip the test runs without notifications in the report, you can pass a special flag silent to the helper as the third argument:

testplane.skip.in("ie8", "skipReason", { silent: true });

Solution 2: .skip.notIn Directive

You might also want to run the test only in a specific browser, for example, in Chrome:

describe("feature", function () {
testplane.skip.notIn("chrome", "it should work only in Chrome");
it("specific functionality", function () {
// ...
});
});

Similarly, to avoid notifications in the report, you can pass a special flag silent to the helper as the third argument:

testplane.skip.notIn("chrome", "skipReason", { silent: true });

Solution 3: .only.in and .only.notIn Directives

You can also use the helpers only.in and only.notIn, whose logic is the opposite of the helpers skip.in and .skip.notIn. Additionally, these helpers do not, by default, produce any notifications in the report:

testplane.only.in("chrome"); // run the test only in Chrome
testplane.only.notIn("ie8"); // run the test in all browsers except IE8

Solution 4: .also.in Directive and Passive Browser Option

If you are introducing a new browser and need to run it only in a few tests while having thousands of them, using the .skip.in helper may be inconvenient. To solve this problem, you can use the passive browser option and the helper .also.in:

testplane.also.in("ie8"); // run the test in the passive browser IE8

Keywords

  • testplane.skip.in
  • testplane.skip.notIn
  • testplane.only.in
  • testplane.only.notIn
  • testplane.also.in