AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
222 stars 20 forks source link

Problem with test dependency #297

Open alekdavisintel opened 1 month ago

alekdavisintel commented 1 month ago

I just noticed a weird issue. I have a number of CRUD tests with dependencies: get some values necessary for item creation, then check if the item with the same name already exists, if so, delete the item, then create the item, do a couple of gets, do a patch, another get, and finally delete. It seems to work fine, if I have a pending account that I need to clean up, but if there is no cleanup account, then I skip the cleanup deletion step and even though the rest of the tests execute as expected (based on the logs), the icons of all of the subsequent tests show as non-tried:

image

In my particular case, only the Clean up existing non-employee acount test must show as skipped. Other tests must show as either successful or failed (a couple of them failed). Here are the entries from the console log:

INFO: ✓ status == 200
INFO: ✓ sourcesJson isArray
INFO: ✓ sourcesJson.length == 1
INFO: ✓ sourcesJson[0].id isString
INFO: ✓ status == 200
INFO: ✓ status == 200
INFO: ✓ managersJson isArray
INFO: ✓ managersJson.length == 1
INFO: ✓ managersJson[0].id isString
INFO: ✓ status == 200
INFO: ✓ accountJson.id isString
INFO: ✓ accountJson.accountName == Alek.Davis.Test2
INFO: ✓ status == 200
INFO: ✓ nonEmployeeIdentitiesJson isArray
INFO: ✖ nonEmployeeIdentitiesJson.length > 0 (AssertionError [ERR_ASSERTION]: nonEmployeeIdentitiesJson.length (0) > 0 - c:\Users\MYUSERNAME\.vscode\extensions\anweber.vscode-httpyac-6.14.0\dist\extension.js:192:46875)
INFO: ✖ nonEmployeeIdentitiesJson[0].id isString (TypeError: Cannot read properties of undefined (reading 'id') - Object.userJS (c:\PROJECTS\POC\Tests\Identities\identities-CRUD.http:115:49)
INFO: ✖ nonEmployeeIdentitiesJson[0].name == {{accountJson.accountName}} (TypeError: Cannot read properties of undefined (reading 'name') - Object.userJS (c:\PROJECTS\POC\Tests\Identities\identities-CRUD.http:116:49)
INFO: ✓ status == 200
INFO: ✓ validatedAccountsJson isArray
INFO: ✖ validatedAccountsJson.length > 0 (AssertionError [ERR_ASSERTION]: validatedAccountsJson.length (0) > 0 - c:\Users\MYUSERNAME\.vscode\extensions\anweber.vscode-httpyac-6.14.0\dist\extension.js:192:46875)
INFO: ✖ validatedAccountsJson[0].id isString (TypeError: Cannot read properties of undefined (reading 'id') - Object.userJS (c:\PROJECTS\POC\Tests\Identities\identities-CRUD.http:134:45)
INFO: ✖ validatedAccountsJson[0].name == {{accountJson.accountName}} (TypeError: Cannot read properties of undefined (reading 'name') - Object.userJS (c:\PROJECTS\POC\Tests\Identities\identities-CRUD.http:135:45)
INFO: ✓ status == 200
INFO: ✓ patchedAccountJson.firstName == Alexander
INFO: ✓ patchedAccountJson.email == alek.davis.test2+updated@example.com
INFO: ✓ patchedAccountJson.phone == +1 9166666666
INFO: ✓ status == 200
INFO: ✓ updatedAccountJson.firstName == Alexander
INFO: ✓ updatedAccountJson.email == alek.davis.test2+updated@example.com
INFO: ✓ updatedAccountJson.phone == +1 9166666666
INFO: ✓ status == 204
alekdavisintel commented 3 weeks ago

I did a bit more testing and can confirm that there are a few issues with the VSCode extension's handling of the cancelled request. Scenario: there are 3 tests in an http file, the first of which should be cancelled, but the other two should run normally. Here is what happens:

I suspect this is an issue with the VSCode extension (and probably more than one).

AnWeber commented 2 weeks ago

@alekdavisintel I introduced a bug with the last release. I underestimated the scope of the $cancel. Unfortunately, it survives the context and this causes subsequent problems. All testRuns after this run, will be interpreted as skipped.. I reverted the change with the commit. But apparently there are still a few errors in the context of disabled or $cancel. CLI skips all regions after first disabled httpregion. The concept I have there does not work. But I realize that it doesn`t work the fast way and I should think about it.

alekdavisintel commented 2 weeks ago

I have not tested CLI, yet, but from what I see in VSCode, it works fine if I run tests from the Testing tree view (either by file or by folder). Actually, the @disabled condition does not work at all, but it did not work before the last update, so no change here, but the $cancel logic works fine (again, only when I use the Testing view). The only problem is the icons after the test run which should reflect the completed (successfull or failed, but not skipped) test results (they show all as skipped). But the test do run.

I do not know the difference between the test runs between the invocation of the Testing view and the Code Lens Send All and Send Selected options and why the behavior is different. Logically, if I test a file from the Testing view or run the Send All/Send Selected (with all tests in the file selected), I'd expect the behavior to be the same, but it's not. Maybe the logic of different test invocation options is different.