-
Notifications
You must be signed in to change notification settings - Fork 674
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
Add the capability to disable page reloading between tests #1770
Comments
It would be nice to see exact scenarios for this first. For now it sounds like we are going to introduce yet another footgun, there each test results depend on previous one. |
I partially agree. But I am sure there are many scenarios where I don't want to refresh whole page between tests. This will optimize test time as well. Just to avoid refresh, I put all the scenarios in one test and use console.log to makesure it passed all scenarios. |
IMHO it's a slippery slope. It's not a good idea to sacrifice consistency for performance. |
I think this would be hugely beneficial for single page applications, but I also think it should be an explicit opt-in so that a user is aware that they are not starting with a blank slate for each test and that people testing regular websites are not affected. One of the things that is more difficult in a SPA is managing the client side state. Every time you refresh the page, the app bootstraps so you're in a pristine state, but some of the more difficult to track bugs in a SPA arise after editing an item, navigating and expecting an unrelated component to be updated. A typical scenario for me would be:
A test like this could be achieved by putting all logic within a Currently a test like this would be written
IMO, a nicer way to write these would be each test has a single responsibility
The fact that it would improve the performance of running the tests in the fixture would be a bonus (for me) rather than the goal. As mentioned by @iexplore in #1509, enabling this via a 'noReloadBetweenTests' option or similar on the fixture would be a great solution to this. |
+1 for adding noReloadBeetweenTests option. |
@inikulin - what about supporting shared step(s) per Fixture (e.g. |
@brettveenstra, If I get you idea right you can try to use |
@oneillci, @classicalConditioning I'm not sure that splitting the test case to several tests helps. For example if you have three tests the second depends on the first one and the third depends on the second: test('test1', () => { // check create user form and create a user });
// no reload
test('test2', () => { // check user is created in some other view });
// no reload
test('test3', () => { // do something else with the user }); For example if the If you put all these actions into one test you have the same. If the test fails TestCafe shows the line where it happens, so you can easily determine what the part of the test is broken. |
@AlexanderMoskovkin Here are my tests:
Test 1:
...
Test 1:
Test 2:
...
Test 1:
Test 2:
... I hope it is clear that in this scenario tests do not depend on each other |
@AlexanderMoskovkin even better is what @brettveenstra is proposing. |
It seems you can try this approach with the current API: const someRole = Role('http://start-page', async t => {
// do some actions
}, { preserveUrl: true });
fixture `fixture1`
.beforeEach(async t => {
await t.useRole(someRole);
});
//... |
@AlexanderMoskovkin this seems to work, thanks. I saw |
@AlexanderMoskovkin thanks for the quick reply ... if that works as you say, is there a reason why the example:
per the documentation, the putting |
I'm sorry, it seems I missed your questions.
@classicalConditioning, A steps for the role initialization function will be executed once for the whole test run. For example, if you have
@brettveenstra Adding |
@AlexanderMoskovkin I get that, however it is not clear from naming conventions being used that |
@AlexanderMoskovkin The restore of cookies/storages solves a lot. |
To be accurate the |
@iexplore, It seems we have a proposal for this (Implement test sections) but now we can't get any estimates about it. |
How speed can be improved, what is not supported at the moment:
|
Hi @raDiesle, It seems the preserveUrl option should meet your needs. Take a look at the example: fixture `My fixture`; // don't set the url here
const role = Role('https://login-page', async t => {
// some login actions that redirects the page to the `https://start-page`
});
test('test-1', async t => {
await t.useRole(role);
// you are on the `https://start-page` here
});
test('test-2', async t => {
await t.useRole(role);
// you are on the `https://start-page` here
}); Note that cookies restoring works properly in this case but it seems it can be problems with local storage values restoring when the |
I am using preserveUrl, so it helps "after you switch to the role" |
Hi @AlexanderMoskovkin is there an intention to implement the 'noReloadBetweenTests' option or another way to control page reloading between tests? I agree with @oneillci point of view towards the organization of tests. |
Sounds like a good idea to provide an option to disable page reload after each test. It would be very handy for testing web forms that only allow you to go to the next section after completing the current section. Would you consider to implement it @AndreyBelym ? |
Hi @lixualinta, our team is discussing this feature right now. I've made a prototype build without test page reloading. It's really dirty and can be extremely unstable, USE IT AT YOUR OWN RISK. All tests in all fixtures must have the same test page URL, otherwise it won't work. You can download it from GitHub: https://github.com/AndreyBelym/testcafe/releases/download/no-reload-demo-1/testcafe-0.20.0-alpha.3.tgz and then install the TGZ archive with |
After using @AndreyBelym no-reload-demo-1 ~400% faster |
how's this going? :) |
As i have read the disablePageReloads() has been release on version 0.21. However, I am using the version 0.22, when i try to call test.disablePageReloads(), it gives error that Property 'disablePageReloads' does not exist on type 'TestFn'. The method is not in the Interface TestFn, it is in src/runner/index.js. Do you have any idea about this? Thanks. |
@AndreyBelym You said |
Hey @VasilyStrelyaev - I noticed that you removed the "Documentation: required" label. Does this mean that disablePageReloads is now documented somewhere? I'd love to take a look at those docs if that is the case as disablePageReloads is a feature that would really be useful to me. Is there a link for the docs? Test Cafe is great by the way :) |
Hi @darrylgrant , We've decided to keep this feature 'for internal use' for now. That's why we didn't announce it in our release notes or mention in the documentation.
|
Thanks @VasilyStrelyaev - I appreciate the info. 👍 |
I would ask to please not forget about this feature @VasilyStrelyaev. I implemented this in different projects and the feedback was always the same. Please make them sequential (the login process with IdentityServer is veeeeeeery slow). I can hack my way, but that is not good. I also give talks about testcafé And the feedback I always get is the same, sequential tests. |
Testcafe team, Do you have any plans to release this feature in the near future? |
Hello team, I tested few scenarios:
Now on above code both test's url are same so page is not reloaded. It types Hello World.
Now in above code after typing Hello it clicks search button, Then it should click on map's button in next screen but page reload's and again comes to www.google.com where there is no map's button. Is there any way to preserve url between tests or stop reloading??? |
Will we see an implementation in the near future? I still don't get why it is not implemented yet |
I understand the "current" implementation is for internal use only, but I just want to report that even the current undocumented implementation does not work when used together with the Roles feature. Using |
Any plans on implementing the feature in order to use with |
Well, my previous suggestion will only work across fixtures using the same
I would love this to be an opt-in so developers may decide about the stability and possible outcomes. As was mentioned above, SPAs are a bit different from a regular websites, which really needed reload prevention. This is the only suggestion. Other than that |
For my usecase, it would make sense if failed tests triggered a reload for the subsequent test. This would significantly simplify writing cleanup code. |
I see that this issue is closed, but there is no official implementation yet as far as I can tell. Am I missing something? This is an important feature for SPA's imho. Could someone give an update on this issue please? |
There are no updates about this feature, this comment completely describes the situation. |
Thanks for the update @AndreyBelym. Here is my 2 cents on the matter.
I just did a quick test with Cypress and they don't reload between tests either, so it should be possible to roll this out if they can do it. Cypress can also run in parallel, although I have not used or tested that feature with the code below. If anything, this flag should be opt-in like @valerii-cognite mentioned in the comment above. I used the following Cypress to test my claim: context('Testcafé homepage', () => {
before(() => {
cy.visit('https://devexpress.github.io/testcafe')
})
it('should have a get started button', () => {
cy.get('.get-started-button').contains('Get Started');
})
it('should have a how it works section', () => {
cy.get('h1').should('have.text', 'How it works!');
})
}) |
I like so much about test cafe but I think this will be a deal breaker for a lot of people testing SPA's. I've followed this thread for about a year now and IMO it's much more of a philosophical difference rather than any technical limitation. It's up the owners of this project to decide the direction they want to pursue and I respect that. But closing this issue flies in the face of how developers of SPA's work and also how they behave at runtime. It strikes me as purism over practicality and I say this with a lot of respect for the testcafe development team as, aside from this, it truly is an excellent tool. IMO, testing SPA's will not be a 1st class citizen in testcafe unless this scenario is addressed |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow. |
Based on the #1509 question. It's actual for the SPA apps.
The text was updated successfully, but these errors were encountered: