Laravel Dusk very slow

Dom

I am learning Laravel Dusk and I am surprised by the slowness of this tool.

I read that the trait database migration could generate these delays. But in my case I don't use this trait.

Example:

enter image description here

Any suggestions to speed up Dusk? I am working on Windows.

Erich

Each page you are testing probably loads in 1-2 seconds, but if your test clicks to another page or interacts with something that uses transitions or animations and has to wait before it can interact, these all add up. There's also probably some test setup overhead that occurs.

But on average, 38 seconds for 6 tests is 6.7 seconds per test, and given the above, I would actually say that's not terribly bad.

How to speed things up:

  1. Directly seed the database with as much test-related data as possible before running the test rather than creating them via your app. (Unless of course you are testing the ability to create that data via the app.)
  2. Minimize the amount of waiting your test has to do by removing transitions. If you have a lot of tests, you might implement a website mode where your frontend looks for a query parameter in the URL and disables them as necessary.
  3. Reduce the amount of setup/overhead for each test. For instance, if each test first hits a login page, that's an extra page load and input that needs to run each time. You can log in once and then perform a series of other inputs. Or better yet, test the login functionality in only one test, then configure the other tests to be logged in already so it presumes the user is already authenticated.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related