Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot mock notification in dusk test #121

Closed
melihovv opened this Issue Feb 11, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@melihovv
Copy link

melihovv commented Feb 11, 2017

I try to write dusk test for password restore feature.

use Illuminate\Auth\Notifications\ResetPassword;

class RestorePasswordTest extends DuskTestCase
{
    use DatabaseMigrations;

    public function testResetPassword()
    {
        $user = factory(User::class)->create();

        $this->browse(function (Browser $browser) use ($user) {
            Notification::fake();

            $browser
                ->visit('/password/reset')
                ->type('email', $user->email)
                ->press('Send Password Reset Link')
                ->assertPathIs('/password/reset');

            Notification::assertSentTo($user, ResetPassword::class);
        });
    }
}

When I run this dusk test it fails with error

There was 1 failure:

1) Tests\Browser\RestorePasswordTest::testResetPassword
The expected [Illuminate\Auth\Notifications\ResetPassword] notification was not sent.
Failed asserting that false is true.

/home/melihovv/Projects/seo-service/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/NotificationFake.php:39
/home/melihovv/Projects/seo-service/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/NotificationFake.php:31
/home/melihovv/Projects/seo-service/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
/home/melihovv/Projects/seo-service/tests/Browser/RestorePasswordTest.php:37

And it actually sends email, not mocks it.
But in other project using browser-kit-testing syntax the same test passes

We cannot use mocking in dusk tests?

laravel/dusk 1.0.5, laravel/framework 5.4.9

@georaldc

This comment has been minimized.

Copy link

georaldc commented Feb 12, 2017

I don't think it's possible at the moment to modify the framework's environment because your test files and dusk run separately. 5.3 testing/unit testing/browserkit works because that isn't the case with those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.