Wait for a specific spec file to execute before running another one – Jasmine / promoter

Tool: protractor 3.3 0,Jasmine 2.4. 1,Selenium Standalone Server.

I have a test suite that contains a large number of spec.js files, each containing unique tests for my application

I am using the maxinstances and shardtestfiles browser functions to start three browsers and run each spec file to reduce the running time of the whole suite (three browsers take about 20 minutes... So it may take more than an hour without it)

My problem is how to tell the tracer that there is a spec file waiting for another spec file to complete before execution For example:

Let me say I have a test, I have a specification file A1 spec,a2. Spec and A3 Spec then I have some similar structure tests or what you have

When I started the protractor with 3 browser instances as expected, A1 spec,a2. Spec and A3 Specs are launched with their own browser instances because their ratio is 1:1 But unless A2 Spec complete, otherwise A3 What if the spec doesn't work? How can this wait happen, or is it just a best practice not to make some tests interdependent?

Solution

You can use the done callback in beforeeach or in any test that takes time to complete asynchronously Any subsequent tests will not run until the tests you are waiting for are completed

Beforeeach example

beforeEach(function(done) {
    setTimeout(function() {
        value = 0;
        done();
    },1);
});

Its example

it("should support async execution of test preparation and expectations",function(done) {
    value++;
    expect(value).toBeGreaterThan(0);
    done();
});

This will be queued according to your needs, but the tests will run in order In order to speed up, you can use promises and when / guard, but this may make things too complicated

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>