Closed imiric closed 2 years ago
This seems buggy:
It tries to clean up the directory after the BrowserType.Launch()
returns.
I Initially thought it was a race condition, maybe the mkdir
needed to be "flushed" somehow before the removeDir
was called. It turns out that the creation and deletion of the temporary directory works as expected, although it's incorrect as @inancgumus mentioned in the above post (cleanup probably should be run in its own goroutine
and perform the cleanup when the context
is closed).
Another process creates the directory if it doesn't exist which is when we run the command to execute
the cmd
to run chrome.
The fix is:
goroutine
and waiting for the context
to close.EDIT
cleanupFunc
that is called from the browser.Close()
func.
Currently (12eeeb5) the temporary Chrome data storage directory is not cleaned up after each test run.
This is especially visible when running tests:
This doesn't seem like a regression and is the way it's always worked, at least going back to v0.1.1.
Suggested solution
To avoid leaving files behind, the extension should by default remove this directory when the test is finished. This should be easier now after the recent
DataStore
refactor.Unless this behavior is wanted, in which case we might consider an env var to control it (
XK6_BROWSER_CLEANUP=0
?) and maybe a newBrowser
option.Integration tests might be good to have as well, since the current
DataStore
unit tests missed this.