-
Notifications
You must be signed in to change notification settings - Fork 676
Snapshot property warnings work incorrectly with loops #5389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was noticing that this same behavior appears to be prevalent within helpers functions as well. If in my I can provide further details if needed. |
Hello @philga7, |
@Ogurecher : Absolutely; details provided as properly anonymized for confidentiality purposes. TestCafe v.1.9.0 I call a helper within my given test function:
The helper is set up accordingly:
The above when ran with the rest of my awaits, etc. within the test function run normally both pre- and post-v1.9.0. However, as mentioned in my previous response, here is the warning I get:
The challenge here is that I use lots of nested functions in order to accomplish what we do. Hopefully TestCafe isn't inadvertently trying to take this ability away or, better yet, can provide a reasonable work-around to this type of functionality if such warnings are insistent upon change :) Let me know if you require additional information. |
@philga7, Thank you for additional details. I couldn't reproduce this issue using your example. To reproduce it, I need more information about the Regarding your concerns: these warnings were implemented to clarify some aspects of our API and to improve User Experience. If your tests work as expected, you can leave them as they are. We are not planning to restrict this functionality. Also, could you please create a separate thread for this issue? |
@Ogurecher: Let me first bring all the functions together before opening up a separate thread, as I think we're dealing with recursive logic that TestCafe is now interpreting as a non-updating snapshot value (per the warning). If we need to make this into a separate thread, I can certainly do so. Here is the complete picture (apologies for not being more specific originally): I call a helper within my given test function:
The
The helper is set up accordingly:
The above when ran with the rest of my awaits, etc. within the test function run normally both pre- and post-v1.9.0. However, as mentioned in my previous response, here is the warning I get:
I hope this helps; let me know! |
@philga7, Thank you for the clarification. Unfortunately, I still can't reproduce the issue. TestCafe 1.9.0 My test page <!DOCTYPE html>
<html>
<body>
<div class='a'>a1</div>
<div class='a'>a2</div>
</body>
</html> My import { Selector } from 'testcafe';
import { validateElementText } from './helpers';
async function findCompanyName(name: string): Promise<any> {
return Selector('.a').withText(`${name}`);
}
fixture `helpers`
.page `./index.html`
test.meta( { test: 'regression' } )
('Sample test case', async t => {
await validateElementText(await findCompanyName('a2'), 'a2');
}); My import { t } from 'testcafe';
export async function validateElementText(element: Selector, label: string): Promise<void> {
await t.expect(element.innerText).contains(label);
} Console command: Please share a repository with a reproducible example. |
@Ogurecher: Thanks for sharing your test. I noticed off the top that you're running under Windows (whereas mine is macOS), and you've explicitly declared your functions (whereas mine are in classes), and your test case is using explicit values (whereas mine are variables). For the declared function aspect, I honestly do believe that if I were re-writing these tests, I'd likely use the Therefore, as originally requested, I'll open up a separate thread (and reference this one) to describe my particular situation. I'll also endeavor to get into as much detail as I can with exactly what I have. Thanks again for the great assist. |
I'm also running into this issue which is making the test logs longer than I'd like them to be. |
@omartaghlabi, There is currently no option to disable these warnings. We'll look into ways to fix the incorrectly raised warning messages in the nearest future so that a workaround will not be necessary. We'll update this thread once the issue is fixed. Thank you for your patience. |
Hi I am getting the same error when looping through: Here is the code:
|
@costag1982, Thank you for the example. It will help us test the fix once it's ready. |
I ran into this problem outside of loops. Simply calling a function that does some assertions twice produces this warning. Here is an example: test('Checkout', async() => {
await addToCart(item); //just some setup
await validatePrice(item.price);
await validatePrice(item.price);
});
const validatePrice = (price) => {
const total = Selector('.class');
return t.expect(total.textContent).contains(price);
} Obviously this usually makes no sense, however the warning also occurs if there are some actions between the two calls (including navigating to different pages) If the assertion is not extracted into a function, there will be no warnings: test('Checkout', async(t) => {
await addToCart(item); //just some setup
let total = Selector('.class');
await t.expect(total.textContent).contains(item.price);
total = Selector('.class'); //this is optional, it works with or without it
await t.expect(total.textContent).contains(item.price);
}); This is with testcafe |
@Khartir, Thank you for the example. We're working on a fix for the issue you outlined in the context of this issue. |
For the team: When the snapshot property promise is resolved, its callsite is saved to a callsite storage. We check this storage in the If the property was not awaited, the |
Hi @Ogurecher. I've run into this too with my Page Objects. How do I figure out when the fix will be available? |
Hello, We are working on the next release version. At the moment, I cannot give you any ETA. However, you can run your tests using our current release candidate version: |
|
Hello, We are happy to hear that the issue is resolved with the |
What is your Test Scenario?
Assert an unawaited snapshot property multiple times in a loop.
What is the Current behavior?
The warning is raised as if the snapshot was awaited.
What is the Expected behavior?
TestCafe should not raise warnings and the test should pass correctly.
Your complete test code (or attach your test files):
Your complete test report:
Your Environment details:
The text was updated successfully, but these errors were encountered: