-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support loading page functions from files using webpack (#19)
* feat: support loading page functions directly from files (using webpack) refactor: improve folder structure * chore: remove unused dependency * dont automatically set babel presets if no presets are provided, fallback to using babelrc config * print warning when a page function already exists * if sourceFiles is a string, assume its a glob path * use limit chunk count webpack plugin * prefer finding node_modules relative from dist dir * refactor BrowserError to be a named export * use array index to access first char * use createCacheKey also for parseFunction * increase test coverage * ignore coverage of deprecated method * fix/improve page function tests * determine valid cache correctly * try enabling puppeteer on ci again * always use tib for cache path improve warning msg * fix test
- Loading branch information
Showing
79 changed files
with
2,154 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules | ||
coverage | ||
test/fixtures/** | ||
src/browsers.js | ||
src/browsers/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Webpage from '../webpage' | ||
import { parseFunction } from '../../utils' | ||
|
||
export default class PuppeteerWebpage extends Webpage { | ||
async open(url, readyCondition = 'body') { | ||
this.page = await this.driver.newPage() | ||
|
||
await this.browser.callHook('page:created', this.page) | ||
|
||
await this.page.goto(url) | ||
|
||
if (readyCondition) { | ||
await this.page.waitFor(readyCondition) | ||
} | ||
|
||
return this.returnProxy() | ||
} | ||
|
||
runScript(pageFunction, ...args) { | ||
let parsedFn | ||
if (typeof pageFunction === 'function') { | ||
parsedFn = parseFunction(pageFunction, args, this.getBabelPresetOptions()) | ||
} else { | ||
parsedFn = pageFunction | ||
} | ||
|
||
// It would be bettter to return undefined when no el exists, | ||
// but selenium always returns null for undefined so better to keep | ||
// the return value consistent | ||
return this.page.evaluate( | ||
/* istanbul ignore next */ | ||
function (fn, ...args) { | ||
return (new (Function.bind.apply(Function, fn))()).apply(null, [].concat(args)) | ||
}, | ||
[null, ...parsedFn.args, parsedFn.body], | ||
...args | ||
) | ||
} | ||
|
||
getHtml() { | ||
/* istanbul ignore next */ | ||
const pageFn = () => window.document.documentElement.outerHTML | ||
return this.page.evaluate(pageFn) | ||
} | ||
|
||
getTitle() { | ||
return this.page.title() | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/utils/commands/static-server.js → src/commands/static-server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.