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

Add evaluate() function #181

Closed
wants to merge 34 commits into from
Closed

Add evaluate() function #181

wants to merge 34 commits into from

Conversation

darron1217
Copy link
Contributor

@darron1217 darron1217 changed the title Add evaluate() function Add evaluate() function + Fix tests error Apr 13, 2018
@darron1217
Copy link
Contributor Author

I've also added tests error fix

@@ -162,20 +162,6 @@ public function it_can_handle_a_permissions_error()
->save($targetPath);
}

/** @test */
public function it_can_use_the_methods_of_the_image_package()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this test because method named format() is overrided. So we cannot access to spatie/image package's function.
(I guess format() function is implemented for setting pdf format)

@@ -201,6 +187,7 @@ public function it_can_create_a_command_to_generate_a_screenshot()
'height' => 1080,
],
'args' => [],
'type' => 'png',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is 'png' added in every test? Can this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It related to #180

This change is not related with this PR. Should I remove it?
(I just tried to remove Travis Error)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it

bin/browser.js Outdated
output = await page[request.action](request.options);
if(request.action == 'evaluate') {
output = await page.evaluate(request.options.pageFunction);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor this, so we don't need an else statement?

First thought: let's introduce a getOutput function. You can use an early return in that function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more about getOutput?

You mean request.action == 'getOutput'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed explicit base64 encoding code.

But I can't make it more simpler because passing request.options can't handle evaluate() function which needs string argument

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That else statement can be avoided by introducing a new function getOutput(request) that returns the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented it on d33189d
Is it the function you said?

@darron1217 darron1217 changed the title Add evaluate() function + Fix tests error Add evaluate() function Apr 16, 2018
@darron1217
Copy link
Contributor Author

I've implemented getOutput() on browser.js

@freekmurze
Copy link
Member

The tests seem to be failing. Can you also add a test for the evaluate function?

@darron1217
Copy link
Contributor Author

The test error is caused by another accepted PR #180
I'll create another PR to fix test error

@freekmurze
Copy link
Member

Thanks! Could you rebase to the current master?

@darron1217
Copy link
Contributor Author

Okay wait for a second

@darron1217
Copy link
Contributor Author

darron1217 commented Apr 18, 2018

I rebased it, and commits are dirty... haha

Wait a second, it's weird

@darron1217
Copy link
Contributor Author

I don't understand how to rebase it....
Can you help me with doing it?

@darron1217
Copy link
Contributor Author

#185
I created cleaned version of this PR

@darron1217 darron1217 closed this Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants