Closed OwenMelbz closed 5 years ago
An update for anybody with similar issues, the way I've currently tried to solve it is using a nasty sleep :(
E.g. my tests look something like
public function testSchoolsCanRegister()
{
$testEmail = 'teststudent';
User::where(['email' => $testEmail])->forceDelete();
$school = factory(School::class)->create();
sleep(1);
$this->browse(function ($browser) use ($school, $testEmail) {
$browser->visit('/register/student')
->type('#school_code', $school->auth_code)
->type('#email', $testEmail)
->type('#password', 'secret')
->check('#tos')
->press('#SignUp')
->assertPathIs('/play');
$school->forceDelete();
$newUser = User::where(['email' => $testEmail])->first();
$this->assertNotNull($newUser);
$this->assertSame($newUser->email, $testEmail);
$newUser->forceDelete();
});
}
public function testPublicCanRegister()
{
$testEmail = 'test@selesti.com';
User::where(['email' => $testEmail])->forceDelete();
sleep(1);
$this->browse(function ($browser) use ($testEmail) {
$browser->visit('/register/public')
->type('#name', 'testUser')
->type('#email', $testEmail)
->type('#password', 'secret');
$browser->driver->executeScript('jQuery("#dob").val("28/03/1991")');
$browser->select('#region', '1')
->check('#tos')
->press('#SignUp')
->assertPathIs('/play');
$newUser = User::where(['email' => $testEmail])->first();
$this->assertNotNull($newUser);
$this->assertSame($newUser->email, $testEmail);
$newUser->forceDelete();
});
}
Getting the same, and adding the sleep, does help.
do you still have phpspec
installed? a couple versions back, a new Laravel install had phpspec
installed by default. It was causing some strange issues for me, and after removing it things worked much better.
@OwenMelbz and @jminkler do you still need help with this?
I guess lol - but issue stands that it tries to execute the commands before the driver is fully booted, so not sure what can be done unless the method is overwritten to wait longer
Is the same problem happening on the up to date version? Meaning you're able to run a single test file, but not the whole suite?
I had the exact same issue. I found this excerpt on; http://php.net/manual/en/features.connection-handling.php
Excerpt: I finally found out what was wrong: The session only gets closed by PHP at the very end of the script, and since access to the session data is locked to prevent more than one page writing to it simultaneously, the new page cannot load until the original processing has finished.
It got me thinking, so I simply did : session()->flush() at the very end of each of my individual test scripts and they all started working together, each one running right after the other, like you would expect. No need for sleep().
Here is what the short version looks like:
class Registration1Test extends DuskTestCase {
public function testRegistrationTest1()
{
$this->browse(function ($browser) {
// run the tests
});
session()->flush();
}
}
I hope this helps!
Unfortunately, this didn't work either 😞
@hemoali if your problem isn't resolved by adding a sleep()
then your issue is probably something different, so probably worth posting your full issue
@hemoali - just a note, my solution didn't work if all my tests were in the same file ( as the script would not have ended as noted in the excerpt above). When I put the tests in their own individual files (allowing for each individual script to end), then it worked like a charm. Not sure if that applies to your situation, but something I noted when testing. Prior to flushing the session info, neither one worked.
getting same, very radnomly.
same bug ( After restart node-chrome in docker, tests passed successfull
This issue is very random even in docker it just happens ever now and then, nothing seem to fix, it.
Any solution yet? Same issue.
I found a solution for this: in my gitlab-runner i have put
shm_size = 536870912
that fixed all "no sessions" errors.
This is my gitlab-runner for docker. @lsfiege
config.toml
concurrent = 1
check_interval = 0
[[runners]]
name = "google-gitlab-runner"
url = "https://xxxxxx/"
token = "xxxxxxx"
executor = "docker"
environment = ["COMPOSER_CACHE_DIR=/cache"]
[runners.docker]
tls_verify = false
image = "php:7.0"
privileged = true
security_opt = ["seccomp:unconfined"]
disable_cache = false
cache_dir = "/cache"
volumes = ["/var/cache:/cache:rw"]
shm_size = 536870912
[runners.cache]
I run this docker image
Where is docker config
Is in /etc/gitlab-runner, here is my config:
concurrent = 1
check_interval = 0
[[runners]]
name = ******************************
url = "https://gitlab.com/"
token = "*************************************"
executor = "docker"
[runners.docker]
tls_verify = false
image = "lsfiege/laravel-dusk-ci"
privileged = true
disable_cache = false
volumes = ["/cache"]
shm_size = 536870912
[runners.cache]
I'm work on Windows 10
I found a solution for this: in my gitlab-runner i have put
shm_size = 536870912
that fixed all "no sessions" errors.
Thanks
Hi,
I'm starting to scaffold a suite of browser tests for a project, however when I run the full suite via
php artisan dusk
90% of the tests fail to due what seems like a race condition.If I run the tests class by class like
php artisan dusk tests/Browser/RegisterTest.php
they always work.It just seems when they're all together they expect your computer to be consistently fast and be able to spin up a chrome instance and load the page before the timeout.
Is there anyway we can make it so it slows down/waits a little longer before trying to run the tests?