Тест Mocha перезапускается и терпит неудачу во второй раз - PullRequest
0 голосов
/ 05 июня 2018

У меня есть тестовый мокко для api node.js.Он перестал работать на прошлой неделе, и когда я вернулся к предыдущей рабочей версии, у меня все еще была проблема.Тесты мокко выполняются в первый раз на всем пути, но в конце они немедленно перезапускаются и все они терпят неудачу.Я использую асинхронную функцию, окружающую тесты:

before(function () {
// runs before all tests in this block
console.log("--- Starting Test using node: " + process.version + " --- 
");

//Log in the guest user
var request = {
    "email": guestTestor.email,
    "password": guestTestor.password,
    "deviceId": 'web'
};
var url = server + login;
apiCall(request, url, function callback(status, result) {
    if (status === 200 && result.code === 0) {
        console.log("----- Guest Login Succeeded -----");
        guestTestor.token = result.message.token.id;
    } else {
        console.log("----- Guest Login Failed -----");
        guestTestor.token = "";
    }
});
console.log("--- Setup up completed (asyncs will finish shortly) ---");
});

after(async function () {
// runs after all tests in this block
await dbcontrol.deleteDocument(guestTestor.token);

console.log("--- Clean up completed ---");
});

Это вывод после завершения всех тестов:

--- Clean up completed ---

  Argis Framework Automated Integration Tests
--- Starting Test using node: v8.11.2 ---
--- Setup up completed (asyncs will finish shortly) ---
    User Creation Process
Error in apiCall:Error: only absolute urls are supported
----- Guest Login Failed -----
Error in apiCall:Error: only absolute urls are supported
----- Admin Login Failed -----
Error in apiCall:Error: only absolute urls are supported
----- Argis Login Failed -----
      Create New User Tests
        4) create user should fail on a bad syntax
        5) create user should fail on user already exists
        6) create user successful awaiting verification
        7) create user successful awaiting verification (for expiration test)
        8) login should fail because the user is not validated
        9) create user should fail because esri identity or password is invalid.
        10) create user should succeed with esri identity as the user created
      Validate New User
(node:7100) UnhandledPromiseRejectionWarning: AssertionError: expected 'get user and verification from database' to equal false
    at C:\Users\Malaika\ArgisAPI\test\testing.js:353:79
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:7100) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:7100) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Я пробовал использовать разные версии мокко и использовать -выход.Есть идеи, почему он может ломаться сейчас и почему он перезапускается в конце?

1 Ответ

0 голосов
/ 07 июня 2018

Проблема заключалась в том, что серверная часть URL-адреса запроса для apiCall перезаписывалась как объект.Тесты выполнялись корректно, используя строку как строку, а затем немедленно перезапускали тесты с сервером в качестве объекта.Я до сих пор не уверен, почему при смене сервера тесты были перезапущены, но я удалил ошибочную строку кода, превращая его в объект, и теперь он работает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...