question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_after hook performed asynchronously

See original GitHub issue

Hi all! I’m newbie in Js, but looks like the _after hook performed asynchronously when restart option disabled. execute('localStorage.clear();') completes after the test, but .deleteCookie() after starting next test.

I have added console.log() to check it

test
 > WebDriverIO._before
 * I am on page "/404"
 > [Url] https://bestsite.com/404/
 √ OK in 9882ms

 > WebDriverIO._after
 > WebdriverCSS._after
 > ForGame._after
 > TestApi._after
 > WebdriverIOExtra._after
 > MobileResolution._after
 > [Session] cleaning cookies and localStorage
Console log: deletestorage <- after test
 test2
 > WebDriverIO._before
Console log: deleteCookie <- during next test
 * I am on page "/404"
 √ OK in 9038ms

Look like we should use something like async in this situation…

BTW, it’s will be great, when restart option disabled to close all tabs in the browser except for one, because if in tests you open new tab, you should mark in code to close it, if you don’t want to open 100+ tabs during the tests.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
APshenkincommented, Nov 25, 2016

@DavertMik still facing this issue( Looks like _after hooks add proper tasks to recorder, but after adding we don’t wait when this tasks will be finished.

Here is trace from selenium:

18:29:00.095 INFO - Executing: [execute script: localStorage.clear();, []])
18:29:00.103 INFO - Executing: [get: https://google.com/])
18:29:00.198 INFO - Done: [execute script: localStorage.clear();, []]
18:29:00.204 INFO - Executing: [delete all cookies])
18:29:02.226 INFO - Done: [get: https://google.com/]
18:29:02.231 INFO - Executing: [get current url])
18:29:02.418 INFO - Done: [delete all cookies]
18:29:02.425 INFO - Done: [get current url]

but it should be like this

18:29:00.095 INFO - Executing: [execute script: localStorage.clear();, []])
18:29:00.198 INFO - Done: [execute script: localStorage.clear();, []]
18:29:00.204 INFO - Executing: [delete all cookies])
18:29:02.418 INFO - Done: [delete all cookies]
18:29:00.103 INFO - Executing: [get: https://google.com/])
18:29:02.226 INFO - Done: [get: https://google.com/]
18:29:02.231 INFO - Executing: [get current url])
18:29:02.425 INFO - Done: [get current url]

Maybe you can give me a tip where to look for the cause of the problem?

0reactions
APshenkincommented, Sep 21, 2016

@DavertMik Any new about this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performing Async Actions using Hooks - Level Up Coding
This simple hook gives us current state action to be performed and a function to perform the action. The body argument is in...
Read more >
How to use async functions in useEffect (with examples)
Using asynchronous functions in a useEffect hook is quite common, notably for data fetching. Let's see several ways of going about it!
Read more >
Using Async Await Inside React's useEffect() Hook
After the component mounts, we let a useEffect hook spin off a quick fetchUsers() call which returns us a Promise type, which we...
Read more >
React Hooks: async function in the useEffect - DEV ...
Async functions always return a promise so you will not have the actual value until the Promise is fulfilled. Anti-Pattern: async function ...
Read more >
How to go async with useEffect - Fernando Abolafio - Medium
1. Defining the async function inside the hook ... setLoading(true); } getData();},[]);. The code above is 100% correct and it will get the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found