{"id":5283,"date":"2017-12-13T14:38:15","date_gmt":"2017-12-13T05:38:15","guid":{"rendered":"https:\/\/www.lancard.com\/blog\/?p=5283"},"modified":"2025-03-12T11:26:06","modified_gmt":"2025-03-12T02:26:06","slug":"laravel-dusk-%e3%83%a1%e3%83%a2","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2017\/12\/13\/laravel-dusk-%e3%83%a1%e3%83%a2\/","title":{"rendered":"Laravel Dusk \u30e1\u30e2"},"content":{"rendered":"<p>Laravel 5.5 \uff06 Laradock(<a href=\"https:\/\/github.com\/laradock\/laradock\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/laradock\/laradock<\/a>)\u74b0\u5883\u3067\u3059\u3002<br \/>\nLaradock\u306b\u3064\u3044\u3066\u306f\u5c11\u3057\u53e4\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093(\u6d3b\u767a\u306b\u66f4\u65b0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u3050\u306b\u53e4\u304f\u306a\u308b)\u3002<\/p>\n<p>Laravel Dusk \u306f\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u3092\u304a\u624b\u8efd\u306b\uff01\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/readouble.com\/laravel\/5.5\/ja\/dusk.html\" rel=\"noopener\" target=\"_blank\">https:\/\/readouble.com\/laravel\/5.5\/ja\/dusk.html<\/a><\/p>\n<p>Laradock\u3067\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u4f7f\u3044\u59cb\u3081\u3066\u3059\u3050\u306e\u30ed\u30b0\u30a4\u30f3\u30c6\u30b9\u30c8\u3067\u4f55\u56de\u304b\u3064\u307e\u3065\u3044\u305f\u306e\u3067\u30e1\u30e2\u3092\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<h1>Laradock\u554f\u984c<\/h1>\n<p>\u307e\u305a\u3001Laradock\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u901a\u308a\u306b\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u3082\u6b63\u5e38\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3067\u3057\u305f(2017\/12\/13\u73fe\u5728)<\/p>\n<p>Laradock\u3067Laravel Dusk\u3092\u52d5\u304b\u3059\u30e1\u30e2(<a href=\"https:\/\/qiita.com\/uenoryo\/items\/bdded2dc6f8e5f2075cc\" rel=\"noopener\" target=\"_blank\">https:\/\/qiita.com\/uenoryo\/items\/bdded2dc6f8e5f2075cc<\/a>)<\/p>\n<p>\u3053\u3061\u3089\u3092\u53c2\u8003\u306b\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u305f\u3060\u3057\u3001selenium\u30b3\u30f3\u30c6\u30ca\u3078\u30d5\u30a9\u30f3\u30c8\u3092\u5165\u308c\u306a\u3051\u308c\u3070\u5931\u6557\u6642\u306a\u3069\u306escreenshot\u3067\u65e5\u672c\u8a9e\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u305f\u3081 laradock\/selenium\/Dockerfile \u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7de8\u96c6\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre><code>FROM selenium\/standalone-chrome\n\nMAINTAINER Edmund Luong &lt;edmundvmluong@gmail.com&gt;\n\nRUN sudo apt-get update &amp;&amp; sudo apt-get install fonts-ipafont -y\n\nEXPOSE 4444\n\n<\/code><\/pre>\n<p>\u305d\u3057\u3066\u30d3\u30eb\u30c9<\/p>\n<pre><code>$ docker-compose up -d --build selenium\n<\/code><\/pre>\n<p>\u3053\u308c\u3067\u8c46\u8150\u305f\u3061(\u25a1\u25a1\u25a1\u25a1\u7684\u306a\u6587\u5b57\u5316\u3051)\u3068\u306f\u304a\u3055\u3089\u3070\u3067\u3059\u3002<\/p>\n<h1>Session\u554f\u984c<\/h1>\n<blockquote class=\"twitter-tweet\" data-lang=\"ja\">\n<p lang=\"ja\" dir=\"ltr\">\u5348\u524d\u4e2d\u3001Laravel\u3078\u306e\u30d6\u30e9\u30a6\u30b6\u3067\u306e\u30ed\u30b0\u30a4\u30f3\u30c6\u30b9\u30c8\u304c\u52d5\u304b\u306a\u3044\u3068\u60a9\u3093\u3067\u305f\u539f\u56e0\u306f\u30bb\u30c3\u30b7\u30e7\u30f3\u30c9\u30e9\u30a4\u30d0\u306barray\u3092\u8a2d\u5b9a\u3057\u3066\u305f\u3068\u3044\u3046\u30aa\u30c1\u3060\u3063\u305f\u30a2\u30ab\u30a6\u30f3\u30c8\u304c\u3053\u3061\u3089\u3002\u5358\u4f53\u30c6\u30b9\u30c8\u7528\u306e\u8a2d\u5b9a\u6d41\u7528\u3057\u3066\u305f\u306e\u304c\u539f\u56e0(\u8abf\u6574\u6f0f\u308c)\u3002<\/p>\n<p>&mdash; murave (@murave) <a href=\"https:\/\/twitter.com\/murave\/status\/940796018286891008?ref_src=twsrc%5Etfw\">2017\u5e7412\u670813\u65e5<\/a><\/p><\/blockquote>\n<p><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>.env.dusk.local \u3067Dusk\u7528\u306e\u8a2d\u5b9a\u304c\u884c\u3048\u308b\u306e\u3067\u3059\u304c\u5358\u4f53\u30c6\u30b9\u30c8\u7528\u306e\u3082\u306e\u3092\u30b3\u30d4\u30fc\u3057\u3066\u4fee\u6b63\u3057\u3066\u3044\u305f\u305f\u3081\u30bb\u30c3\u30b7\u30e7\u30f3\u306barray\u30c9\u30e9\u30a4\u30d0\u3092\u8a2d\u5b9a\u3057\u3066\u305f\u306e\u3067\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/readouble.com\/laravel\/5.5\/ja\/session.html\" rel=\"noopener\" target=\"_blank\">https:\/\/readouble.com\/laravel\/5.5\/ja\/session.html<\/a><\/p>\n<blockquote><p>\n  array &#8211; \u30bb\u30c3\u30b7\u30e7\u30f3\u306fPHP\u306e\u914d\u5217\u3068\u3057\u3066\u4fdd\u5b58\u3055\u308c\u308b\u3060\u3051\u3067\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u9593\u3067\u7d99\u7d9a\u3057\u307e\u305b\u3093\u3002\n<\/p><\/blockquote>\n<p>\u3067\u3059\u3088\u306d\u301c\u3002<\/p>\n<p>\u4ed6\u74b0\u5883\u3078\u306e\u5f71\u97ff\u3092\u6291\u3048\u308b\u305f\u3081\u306bCookie\u30c9\u30e9\u30a4\u30d0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre><code>SESSION_DRIVER=cookie\n<\/code><\/pre>\n<h1>Transaction\u554f\u984c<\/h1>\n<p>\u30c6\u30b9\u30c8\u958b\u59cb\u6642\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30af\u30ea\u30a2\u3057\u3066\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3057\u3066\u30de\u30b9\u30bf\u30fc\u7528\u306eSeeder\u3067\u30de\u30b9\u30bf\u30fc\u6e96\u5099\u3057\u3066Faker\u3067\u30e6\u30fc\u30b6\u30fc\u4f5c\u3063\u3066\u3001\u307f\u305f\u3044\u306b\u3084\u308b\u3058\u3083\u306a\u3044\u3067\u3059\u304b\u3002<\/p>\n<p>Laravel 5.5 \u306b\u306fRefreshDatabase\u3068\u3044\u3046\u4fbf\u5229\u30c8\u30ec\u30a4\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/readouble.com\/laravel\/5.5\/ja\/database-testing.html\" rel=\"noopener\" target=\"_blank\">https:\/\/readouble.com\/laravel\/5.5\/ja\/database-testing.html<\/a><\/p>\n<blockquote><p>\n  \u524d\u306e\u30c6\u30b9\u30c8\u304c\u305d\u306e\u5f8c\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u5f71\u97ff\u3057\u306a\u3044\u3088\u3046\u306b\u3001\u5404\u30c6\u30b9\u30c8\u306e\u5f8c\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30ea\u30bb\u30c3\u30c8\u3067\u304d\u308b\u3068\u4fbf\u5229\u3067\u3059\u3002\u30a4\u30f3\u30e1\u30e2\u30ea\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3044\u3066\u3082\u3001\u30c8\u30e9\u30c7\u30a3\u30b7\u30e7\u30ca\u30eb\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u3082\u3001RefreshDatabase\u30c8\u30ec\u30a4\u30c8\u306b\u3088\u308a\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306b\u6700\u9069\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u304c\u53d6\u308c\u307e\u3059\u3002\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u3066\u3053\u306e\u30c8\u30ec\u30a4\u30c8\u3092\u4f7f\u3046\u3060\u3051\u3067\u3001\u5168\u3066\u304c\u51e6\u7406\u3055\u308c\u307e\u3059\u3002\n<\/p><\/blockquote>\n<p>\u305d\u3046\u3001\u5168\u3066\u304c\u51e6\u7406\u3055\u308c\u308b\u306e\u3067\u3059\u3002\u5f71\u97ff\u304c\u6b8b\u3089\u306a\u3044\u3088\u3046\u306bTransaction\u4e2d\u306b\u51e6\u7406\u3057\u3066Rollback\u307e\u3067\u3057\u3066\u304f\u308c\u308b\u3002\u4fbf\u5229\u3002<\/p>\n<p>\u3060\u304c\u601d\u3044\u51fa\u305d\u3046\u3002\u30d6\u30e9\u30a6\u30b6\u30c6\u30b9\u30c8\u3060\u3068\u3044\u3046\u3053\u3068\u3092\u3002<\/p>\n<p>\u30da\u30fc\u30b8\u9077\u79fb\u3057\u305f\u3089\u30c7\u30fc\u30bf\u6d88\u3048\u308b\u308f\u3051\u3067\u3001\u3046\u3063\u304b\u308aRefreshDatabase\u30c8\u30ec\u30a4\u30c8\u3092\u4f7f\u3046\u3068\u60f3\u5b9a\u901a\u308a\u306b\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3093\u306a\u308f\u3051\u3067\u3001\u30ea\u30bb\u30c3\u30c8\u3057\u3066\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u307e\u3067\u3060\u3051\u3057\u3066\u304f\u308c\u308bDatabaseMigrations\u30c8\u30ec\u30a4\u30c8\u306e\u307b\u3046\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4f8b<\/p>\n<pre><code>&lt;?php\nnamespace Tests\\Browser;\nuse Tests\\DuskTestCase;\nuse Laravel\\Dusk\\Browser;\nuse Illuminate\\Foundation\\Testing\\DatabaseMigrations;\nuse App\\User;\n\nclass LoginTest extends DuskTestCase\n{\n    use DatabaseMigrations;    \/\/\u5b9f\u884c\u6642DB\u5185\u5bb9\u306f\u6d88\u3048\u308b\n\n    public function testLogin()\n    {\n        \\Artisan::call('db:seed', ['--class' =&gt; 'MasterSeeder']);\n        $user = factory(User::class)-&gt;create();\n\n        $this-&gt;browse(function (Browser $browser) use ($user) {\n            $browser-&gt;visit('\/login')\n                    -&gt;type('email', $user-&gt;email)\n                    -&gt;type('password', 'secret')\n                    -&gt;press('\u30ed\u30b0\u30a4\u30f3')\n                    -&gt;assertPathIs('\/home');\n        });\n    }\n}\n<\/code><\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306fDatabaseMigrations\u3067\u518d\u69cb\u7bc9\u3055\u308c\u305f\u307e\u3063\u3055\u3089\u306a\u72b6\u614b\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30de\u30b9\u30bf\u30fc\u7cfb\u6295\u5165\u7528\u306eMasterSeeder\u3092\u5b9f\u884c\u3057\u305f\u5f8c\u306b\u30c6\u30b9\u30c8\u7528\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u3066\u30ed\u30b0\u30a4\u30f3\u51e6\u7406\u306e\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283&#038;t=Laravel%20Dusk%20%E3%83%A1%E3%83%A2&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=Laravel%20Dusk%20%E3%83%A1%E3%83%A2\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283&#038;text=Laravel%20Dusk%20%E3%83%A1%E3%83%A2\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283&#038;title=Laravel%20Dusk%20%E3%83%A1%E3%83%A2\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=Laravel%20Dusk%20%E3%83%A1%E3%83%A2&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Laravel%20Dusk%20%E3%83%A1%E3%83%A2&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5283\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>Laravel 5.5 \uff06 Laradock(https:\/\/github.com\/laradock\/laradock)\u74b0\u5883\u3067\u3059\u3002 Laradock\u306b\u3064\u3044\u3066\u306f\u5c11\u3057\u53e4\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093(\u6d3b\u767a\u306b\u66f4\u65b0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u3050\u306b\u53e4\u304f\u306a\u308b [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[153,130],"class_list":["post-5283","post","type-post","status-publish","format-standard","hentry","category-php","tag-docker","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=5283"}],"version-history":[{"count":5,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5283\/revisions"}],"predecessor-version":[{"id":5288,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5283\/revisions\/5288"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=5283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=5283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=5283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}