-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
100,384 additions
and
1 deletion.
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
33,082 changes: 33,082 additions & 0 deletions
33,082
...a-navigation-block-to-be-created-using-existing-pages-2-2020-11-12t13-24-23-snapshot.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+25.1 KB
...a-navigation-block-to-be-created-using-existing-pages-2-2020-11-12t13-24-23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33,082 changes: 33,082 additions & 0 deletions
33,082
...s-a-navigation-block-to-be-created-using-existing-pages-2020-11-12t13-24-16-snapshot.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+23.8 KB
...s-a-navigation-block-to-be-created-using-existing-pages-2020-11-12t13-24-16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33,082 changes: 33,082 additions & 0 deletions
33,082
...s-a-navigation-block-to-be-created-using-existing-pages-2020-11-12t13-27-02-snapshot.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+23.7 KB
...s-a-navigation-block-to-be-created-using-existing-pages-2020-11-12t13-27-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,54 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const fs = require( 'fs' ); | ||
const util = require( 'util' ); | ||
const root = process.env.GITHUB_WORKSPACE || __dirname + '/../../../'; | ||
const ARTIFACTS_PATH = root + '/artifacts'; | ||
|
||
const writeFile = util.promisify( fs.writeFile ); | ||
|
||
if ( ! fs.existsSync( ARTIFACTS_PATH ) ) { | ||
fs.mkdirSync( ARTIFACTS_PATH ); | ||
} | ||
|
||
/** | ||
* Gutenberg uses the default jest-jasmine2 test runner that comes with Jest. | ||
* Unfortunately, version 2 of jasmine doesn't support async reporters. It | ||
* does support async before and after hooks though, so the workaround here | ||
* works by making each test wait for the artifacts before starting. | ||
* | ||
* Kudos to Tom Esterez (@testerez) for sharing this idea in https://github.com/smooth-code/jest-puppeteer/issues/131#issuecomment-424073620 | ||
*/ | ||
let artifactsPromise; | ||
// eslint-disable-next-line jest/no-jasmine-globals | ||
jasmine.getEnv().addReporter( { | ||
specDone: ( result ) => { | ||
if ( result.status === 'failed' ) { | ||
artifactsPromise = storeArtifacts( result.fullName ); | ||
} | ||
}, | ||
} ); | ||
|
||
beforeEach( () => artifactsPromise ); | ||
afterAll( () => artifactsPromise ); | ||
|
||
async function storeArtifacts( testName ) { | ||
const slug = slugify( testName ); | ||
await writeFile( | ||
`${ ARTIFACTS_PATH }/${ slug }-snapshot.html`, | ||
await page.content() | ||
); | ||
await page.screenshot( { path: `${ ARTIFACTS_PATH }/${ slug }.jpg` } ); | ||
} | ||
|
||
function slugify( testName ) { | ||
const datetime = new Date().toISOString().split( '.' )[ 0 ]; | ||
const readableName = `${ testName } ${ datetime }`; | ||
const slug = readableName | ||
.toLowerCase() | ||
.replace( /:/g, '-' ) | ||
.replace( /[^0-9a-zA-Z \-\(\)]/g, '' ) | ||
.replace( / /g, '-' ); | ||
return slug; | ||
} |
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
Oops, something went wrong.