Rayrun
← Back to Discord Forum

Do fixtures lessen cpu resources?

Instead of doing a beforeEach, would a fixture lessen the cpu and ram resources?

This thread is trying to answer question "Do fixtures lessen cpu resources?"

7 replies
refactoreric

Maybe they do take a bit of ram resources (because of a larger stack trace?) but I think it should be negligible. Why are you worrying about it?

I am thinking about refacoring my tests to use fixtures instead of page objects. My goal is to get these tests passing in the Azure devops pipeline. They pass locally as of right now. But I have a powerful 10 cpu ryzen on my local system. The Azure pipeline linux agent only has 2 cpus.

refactoreric

The browser is probably using more resources than the NodeJS processes running the tests. I think fixtures vs page objects won't make much of a difference in resource usage.

ok, thank you

Unless you make the fixture an automatic fixture, the benefit is that you only initialize what you need, when you need it.

Oh, I thought the benefit was test isolation?

Fixtures encapsulate setup and teardown in the same place so it is easier to write.

refactoreric

Each test requests what it needs, and the fixtures take care of setting up and tearing down those dependencies, so tests don't have to rely on dependencies which were set up (for example) by a test.beforeAll and are less likely the re-use resources. So that's the isolation.

Honestly the isolation is not perfect though, because stuff we put into databases doesn't magically disappear. We do however start with a fresh browser context.

Now I realize that you were not just comparing page objects by fixtures, I have to admit that fixtures will take a bit more resources if you previously used a test.beforeAll and now want each test to do its own setup, possibly repeating some things which were already done for a previous test.

TwitterGitHubLinkedIn
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.