简体   繁体   English

我只能同时运行7个QUnit测试

[英]I can run only 7 QUnit tests at the same time

I have got a problem with running QUnit tests. 我在运行QUnit测试时遇到问题。 I have some async tests on my page. 我的页面上有一些异步测试。

var sendInvalidData = function (httpMethod, data) {
    $.ajax({
        url: '@AppSettings.ApiUrl' + 'api/parties',
        type: httpMethod,
        headers: { 'Authorization': 'Bearer ' + accessToken },
        dataType: "json",
        data: data,
        timeout: 5000
    }).done(function (response) {
        ok(!response.Success, _.first(response.Errors));
    }).fail(function (x, text, thrown) {
        ok(false, "Ajax failed: " + text);
    }).always(function () {
        start();
    });
};

asyncTest("GET api/parties/Available", function () {
    $.ajax({
        url: '@AppSettings.ApiUrl' + 'api/parties/Available',
        type: "GET",
        headers: { 'Authorization': 'Bearer ' + accessToken },
        timeout: 5000
    }).done(function (data) {
        ok(data.Success, "Is response success");
    }).fail(function (x, text, thrown) {
        ok(false, "Ajax failed: " + text);
    }).always(function () {
        start();
    });
});

asyncTest("POST api/parties", function () {
    // The Name field is required.
    sendInvalidData("POST" ,{
        IsPrivate: false,
        Color: 1
    });

    sendInvalidData("POST", {
        Name: "new party",
        Color: 1
    });

    sendInvalidData("POST", {
        Name: "new party",
        IsPrivate: true,
        Color: 1
    });

    sendInvalidData("POST", {
        Name: "new party",
        IsPrivate: false
    });

    sendInvalidData("POST", {
        Name: "new party",
        IsPrivate: false,
        Password: "123",
        Color: 1
    });

    $.ajax({
        url: '@AppSettings.ApiUrl' + 'api/parties',
        type: "POST",
        headers: { 'Authorization': 'Bearer ' + accessToken },
        dataType: "json",
        data: {
            Name: "new party",
            IsPrivate: false,
            Color: 1
        },
        timeout: 5000
    }).done(function (response) {
        ok(response.Success, "Party has created successfully.");
    }).fail(function (x, text, thrown) {
        ok(false, "Ajax failed: " + text);
    }).always(function () {
        start();
    });
});

asyncTest("POST api/parties", function () {
    // another N tests
});

// more async tests

All tests were run clear and passed separately. 所有测试均运行清晰并分别通过。 But if they were running at the same time, only the first 7 tests were run. 但是,如果它们同时运行,则仅运行前7个测试。

I think I miss out something... Can you help me? 我想我错过了一些事情...您能帮我吗?

我已经通过将每个ajax请求包装在asyncTest()方法中解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM