eWert-Online / OSnap

OSnap is a snapshot testing tool, which mainly focuses on speed and ease of use.
https://ewert-online.github.io/OSnap/
152 stars 2 forks source link

Feature: before tests hook #41

Closed amiarSlimane closed 1 year ago

amiarSlimane commented 1 year ago

for example allow login before running the screenshots, in my case i am obliged to put parallelism to 1 to do login first then doing the others one by one, but if we have where to say do this first then do everything else , it would be great, thanks

eWert-Online commented 1 year ago

Wouldn't this be the same as what functions can already do? (#5) I do even have the login function as an example on the documentation page: https://ewert-online.github.io/OSnap/Setup/configuration#example

Do you think functions would be a viable solution for you?

What you definitely should not do is using a test to login. All tests should be isolated from each other, because OSnap does not guarantee any specific order of the tests. Session cookies are also deleted between tests, so as long as you are not storing your session in a local storage, this shouldn't even maintain the login status (#20).

amiarSlimane commented 1 year ago

thank you, yes that will be the solution (handling the login outside the test), for now i use login function as you stated in the doc

[
  {
    "name": "-login",
    "url": "/login",
    "actions": [
      {
        "action": "function",
        "name": "accept_cookies"
      },
      {
        "action": "function",
        "name": "login"
      }
    ]
  },
  {
    "name": "loggedin-index",
    "url": "/"
  },
  {
    "name": "loggedin-social-index",
    "url": "/social/index"
  },
  {
    "name": "loggedin-social-ourmission",
    "url": "/social/ourmission"
  },
  {
    "name": "loggedin-tour-business",
    "url": "/tour-business"
  },....

{
   ...
  "parallelism": 1,
  "functions": {
    "accept_cookies": [
      {
        "action": "click",
        "selector": "#cookie-accept"
      }
    ],
    "login": [
      {
        "action": "type",
        "selector": "#input_identification",
        "text": "test@test.com"
      },
      {
        "action": "type",
        "selector": "#input_password",
        "text": "password"
      },
      {
        "action": "click",
        "selector": "#login"
      },
      {
        "action": "wait",
        "timeout": 4000
      }
    ]
  }
}