← Back to Discord Forum

Is it possible to do E2E testing in playwright using mock data?

fs_projectsposted in #help-playwright
Open in Discord

I have written E2E tests for my application. My manager wants some selected tests to run in CI pipeline. I ran those selected tests locally and found that it was taking around 20 mins to execute in serial mode and 11 mins in parallel mode. In CI pipeline I don't know what will be these stats as I don't know the compute power. Anyways, it's a huge duration and these tests will run whenever there is a push in main branch via a PR and no one will like to wait for this long to get their PR deployed.

  1. Is running these tests in a CI pipeline makes sense?

  2. Or I should run these tests only before any release to production to ensure that all major functionalities are working fine and run unit tests in CI pipeline instead(which we don't have as of now)?

  3. Or Is there a way to mock data and run the tests? Maybe it will reduce the time drastically?

Any thoughts please. Thanks!

This thread is trying to answer question "Is it possible to do E2E testing in playwright using mock data?"

9 replies

We shouldn’t be mocking the data for E2E testing, I believe.

@harry_aujla: Why not?

Why not?

It's OK for end-to-end tests to mock some third party APIs which you want to exclude (just to not have your tests depend on systems which are out of your control).

But as soon as you are mocking /your own/ backend APIs, it's no longer an end-to-end test. Then I would call it a frontend test (which may still be valuable to have, in addition to e2e tests).

End-to-end tests should run automatically somewhere in the process between commit and deployment to production. If they are taking too long, maybe you can split up the product into areas that can be tested and deployed separately, so for each commit there is a smaller selection of tests to run.

thank you @harry_aujla @whitemc2 @refactoreric for sharing your views. Yes the backend apis are ours only not any third party apis. I am thinking to make my manager understand that these are E2E tests and are holistically testing the application so it will take time. As an alternative I can mock our backend APIs and run the test fast but with a compromise, now the test won't be E2E tests but frontend tests like @refactoreric mentioned.

@refactoreric could you please give me an example of last part you suggested related to splitting up the product etc. I didn't get it. Thanks.

What's the average duration per test? Are you creating test data in each test?

I would not mock anything if you don’t have to. I am in the middle of faking some events from 3rd parties due to environment constraints and it’s a nightmare.

If tests take too long I recommend just running on a schedule 3-4 times a day and people just watch them.

In my experience running off pipeline triggers is just crappy in most cases. It’s slow, sometimes outside dependencies change or other areas of your product, that aren’t in the pipeline change, and breaks are not known for a long time.

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.