xvrh / puppeteer-dart

A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
BSD 3-Clause "New" or "Revised" License
236 stars 59 forks source link

Consider defaulting `.local-chrome/` to `.dart_tool/puppeteer/local-chrome/` #329

Open jonasfj opened 4 months ago

jonasfj commented 4 months ago

I imagine that the most common use case for package:puppeteer is to run from test. Probably inside test/mytestcase_test.dart, which is then triggered by dart test (or flutter test).

In such scenarios must application developers have a .dart_tool/ folder which is almost always listed in .gitignore.

Note that the "Project-specific caching for tools" section of the "Package layout conventions" specifies that packages are allowed to cache things in .dart_tool/<package>/.

When .dart_tool/ exists, consider using .dart_tool/puppeteer/local-chrome/ as the default place to cache chrome. If .dart_tool/ doesn't exist, then using a different folder might make more sense (or one could simply choose to throw StateError and demand that the caller supplies a location).

You can find .dart_tool/ using: Isolate.packageConfigSync?.resolve('.').toFilePath() (assuming it's not null)

This would make puppeteer a bit nicer to use in tests. But also note that if you do this, it might be important keep track of when .dart_tool/puppeteer/local-chrome/ needs to be deleted. If you want to update the chrome version you've downloaded it's your responsibility to clear this cache folder (.dart_tool/puppeteer/).


also, HUGE thanks building this really awesome package! :rocket: