← Back to Discord Forum

How to skip authentication test (project dependent tests) when it is already logged in ?

I am writing tests for a typical SPA app that is behind an auth wall. I have a separate authentication tests that is run before the other tests. I use playwright project dependent feature to setup the auth tests and the rest of the tests. In CI, it's ok. As expected, auth tests run before running the other tests.

However, locally, every time I need to rerun and debug the specific test, it needs to rerun the auth tests, and then the specific test I work on. Since auth tests run every time, authentication is done every time, and creating unnecessary loads on the server.

The authentication state is also written to disk as described in the docs. Thus, when the authentication is already done locally, I'd like to skip the auth tests and run the specific test directly.

How can I do this either from the playwright config or from test file ? One way I can think of is check the auth state path, and if exist, skip the auth tests. And have a separate command to update the auth state.

Do you have any other idea apart from that ?

Thanks you very much!

This thread is trying to answer question "How can the user skip authentication tests when already logged in for a SPA app using playwright project dependent feature?"

0 replies
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.