feat: Ability to snapshot a directory of webpages. Usage: percy snapshot directory/ - #137
Conversation
e5d7a97 to
13d5c1c
Compare
3abe787 to
b6f99e7
Compare
b6f99e7 to
146f198
Compare
| "test": "npm run build-client && PERCY_TOKEN=abc mocha --forbid-only \"test/**/*.test.ts\" --exclude \"test/percy-agent-client/**/*.test.ts\" --exclude \"test/integration/**/*\"", | ||
| "test-client": "mkdir -p dist-test/ && npm run build-client-test && testem ci --file ./test/percy-agent-client/testem.js", | ||
| "test-integration": "npm run build-client && node ./bin/run exec -- mocha test/integration/**/*.test.ts", | ||
| "test-snapshot-command": "./bin/run snapshot test/integration/testStaticSite -b /dummy-base-url -i '(red-keep)' -c '\\.(html)$'", |
There was a problem hiding this comment.
The test site has been built with this exact command and arguments in mind. Changing this command could require changing the test site.
But json files don't have comments so there's no great place to document that.
| return this.options | ||
| } | ||
|
|
||
| async _buildPageUrls() { |
There was a problem hiding this comment.
This is where most of the magic happens. This command walks the local directory and looks at each file in the directory.
There was a problem hiding this comment.
Using globby instead of walk makes this function even simpler
cadeParade
left a comment
There was a problem hiding this comment.
Come for the GoT spoilers, stay for the typos
| const ignoreFilesRegex = flags['ignore-files'] as string | ||
| const snapshotFilesRegex = flags['snapshot-files'] as string | ||
| const rawIgnoreGlob = flags['ignore-files'] as string | ||
| const rawSnapshotGlob = flags['snapshot-files'] as string |
There was a problem hiding this comment.
these globs will come in as strings and need to be converted to an array of strings to work with the globby package
| if (this.server) { await this.server.close() } | ||
| } | ||
|
|
||
| _buildLocalUrl() { |
|
|
||
| }) | ||
|
|
||
| describe('#_buildPageUrls without the ignore flag set', () => { |
There was a problem hiding this comment.
this test covers the case when the ignore flag is an empty array
|
|
||
| const snapshotGlobs = rawSnapshotGlob.split(',') | ||
|
|
||
| const ignoreGlobs = rawIgnoreGlob ? rawIgnoreGlob.split(',') : [] |
There was a problem hiding this comment.
Split on an empty string results in an array of an empty string. Globby thinks an empty string means all files, and we def do not want to ignore all files by default. If the raw string is empty then the empty string is falsey and we pass an empty array to the static snapshot service, otherwise we pass an array of the ignore globs.
percy snapshot directory/
percy snapshot directory/percy snapshot directory/
# [0.4.0](v0.3.1...v0.4.0) (2019-04-26) ### Features * Ability to snapshot a directory of webpages. Usage: `percy snapshot directory/` ([#137](#137)) ([20daabb](20daabb))
Description
This adds a service to support taking snapshots of static sites. Now, instead of having to install a higher level SDK and then add the Percy
snapshotcommand to tests, if you have a pre-compiled, server-ready directory of filespercy-agentcan snapshot them with ease.A large chunk of this PR is a simple test site that was built independent of any static site generators. It contains non-final-season Game of Thrones spoilers. You've had 2 years to catch up.