BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

Is there a cleanup hook that can be used to log out of the web service being tested?

Open mountaindude opened this issue 4 years ago • 2 comments

Greetings,

I'd like to run scenarios against a web app that requires login before the test can commence. No worries, the onReady.js hooks deals with this.

The problem is that the web app keeps records of user sessions (combo of userId + session id) and only allows max 10 sessions per user. After that it's not possible to log on => not possible to run tests. So I need to log out when tests are done.

A clean solution would be to log out in a cleanup function, but there doesn't seem to be any such hooks... or?

I thought about driving Backstop from a Node.js app, but I don't think the browser instance created by Backstop exists after the test initiated in the Node.js app is complete.

Ideas/suggestions?

Thanks!

mountaindude avatar May 20 '21 17:05 mountaindude

Yup, there is no cleanup per se. but it would be really easy to do this on the command line or as you mentioned, using BackstopJS as a node module returns you a promise-- so you can run a cleanup script after that. There is more on node module usage in the docs. Hope this helps.

garris avatar May 21 '21 04:05 garris

Thx for the quick reply.

I understand that I get a promise back, but does that include also the browser session that was used? The thing is that once I disconnect from the web service under test I also loose any chance of properly logging out from it. Which means a user session (for the web service under test) will be left dangling until it eventually times out (like 30 minutes).

I.e. I somehow have to retain a reference to the browser that was used. Or possibly return (to the surrounding Node.js app) the value of the session cookie created by the web service under test, and then use that from within the Node.js app to re-connect (using the previously used session ID) to the web service under test and do a proper logout..

I guess it comes down to whether the BackstopJS' promise can resolve with a custom value ?

mountaindude avatar May 21 '21 07:05 mountaindude