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

Log console content into files #139

Merged
merged 1 commit into from
Mar 1, 2017
Merged

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Feb 20, 2017

This PR adds the functionality of storing the browser console content into files for further inspection. Upon installation a Browser/console directory will be created to store the log files of each test.

An example log file looks like:

[
    {
        "level": "SEVERE",
        "message": "http:\/\/duskproject.dev\/ 18:28 Uncaught TypeError: Cannot read property 'undefined' of null",
        "source": "javascript",
        "timestamp": 1487615364745
    }
]

@devinfd
Copy link
Contributor

devinfd commented Feb 20, 2017

:)

@SebastianS90
Copy link
Contributor

That looks really nice! I think it would be useful to have the logs accessible within your tests via a fluent API and already before ::browse() finishes. For example:

$browser
    ->visit('/')
    ->doSomething()
    ->assertLogEmpty()
    ->doSomethingElseThatLogsMessages()
    ->assertLogContains('this is a message I expect to be in the browser log');

Javascript frameworks like vue print log messages when you are using them in a wrong way (only enabled when compiling with env != production). Using such assertions can help to catch that in your test suite.

Just an idea, feel free to ignore it 😆

@taylorotwell taylorotwell merged commit b741ecb into laravel:master Mar 1, 2017
@SeoFood
Copy link

SeoFood commented Mar 1, 2017

could you add a .gitignore file same as the screenshot dir? Because if I just check out the Project I get an error:

Browser/console/testBasicExample-0.log): failed to open stream: No such file or directory

@bbashy
Copy link
Contributor

bbashy commented Mar 2, 2017

Same thing. Need to create folder automatically?

1) Tests\Browser\ExampleTest::testExample
ErrorException: file_put_contents(/path/to/project/tests/Browser/console/testExample-0.log): failed to open stream: No such file or directory

@sileence
Copy link
Contributor

sileence commented Mar 2, 2017

@taylorotwell since this was merged, is there any possibility you could reconsider storing the HTML output as well? #118

(I could rework the PR to make the code better, etc.)

@SebastianS90
Copy link
Contributor

@bbashy It's created when running php artisan dusk:install but not when upgrading dusk to a new version.
But running dusk:install again is a bad idea because it will overwrite some files you might have changed.

We should wrap these commands in if (! file_exists(...)) and then we can recommend to run dusk:install again after an upgrade.

@SeoFood
Copy link

SeoFood commented Mar 2, 2017

yeah and there is no .gitignore file in the console dir.

@SebastianS90
Copy link
Contributor

When #166 is merged and tagged and you have upgraded dusk to the new version, then you can just run php artisan dusk:install again and it will create the folder together with a .gitignore file for you without overwriting existing files.

Until then, you should just create the tests/Browser/console folder and the tests/Browser/console/.gitignore file manually.

@rogervila
Copy link
Contributor

I think dusk should create the console directory with the .gitignore file if they are missing when it runs.

#167

@SebastianS90
Copy link
Contributor

@rogervila sounds even better than my PR. And it might also be good to purge old logs on each run (as we already do with screenshots)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants