|
@@ -47,28 +47,8 @@ console.null = () => {};
|
|
|
|
|
|
/* Launch server */
|
|
/* Launch server */
|
|
|
|
|
|
-const server = http.createServer( ( request, response ) => {
|
|
|
|
-
|
|
|
|
- return handler( request, response );
|
|
|
|
-
|
|
|
|
-} );
|
|
|
|
-server.listen( port, async () => {
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
-
|
|
|
|
- await pup;
|
|
|
|
-
|
|
|
|
- } catch ( e ) {
|
|
|
|
-
|
|
|
|
- console.error( e );
|
|
|
|
-
|
|
|
|
- } finally {
|
|
|
|
-
|
|
|
|
- server.close();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-} );
|
|
|
|
|
|
+const server = http.createServer( ( req, resp ) => handler( req, resp ) );
|
|
|
|
+server.listen( port, async () => await pup );
|
|
server.on( 'SIGINT', () => process.exit( 1 ) );
|
|
server.on( 'SIGINT', () => process.exit( 1 ) );
|
|
|
|
|
|
|
|
|
|
@@ -122,7 +102,7 @@ const pup = puppeteer.launch( {
|
|
/* Loop for each file, with CI parallelism */
|
|
/* Loop for each file, with CI parallelism */
|
|
|
|
|
|
let pageSize, file, attemptProgress;
|
|
let pageSize, file, attemptProgress;
|
|
- let failedScreenshots = 0;
|
|
|
|
|
|
+ let failedScreenshots = [];
|
|
const isParallel = 'CI' in process.env;
|
|
const isParallel = 'CI' in process.env;
|
|
const beginId = isParallel ? Math.floor( parseInt( process.env.CI.slice( 0, 1 ) ) * files.length / 4 ) : 0;
|
|
const beginId = isParallel ? Math.floor( parseInt( process.env.CI.slice( 0, 1 ) ) * files.length / 4 ) : 0;
|
|
const endId = isParallel ? Math.floor( ( parseInt( process.env.CI.slice( - 1 ) ) + 1 ) * files.length / 4 ) : files.length;
|
|
const endId = isParallel ? Math.floor( ( parseInt( process.env.CI.slice( - 1 ) ) + 1 ) * files.length / 4 ) : files.length;
|
|
@@ -212,7 +192,7 @@ const pup = puppeteer.launch( {
|
|
if ( ++ attemptId === maxAttemptId ) {
|
|
if ( ++ attemptId === maxAttemptId ) {
|
|
|
|
|
|
console.red( `WTF? 'Network timeout' is small for your machine. file: ${ file } \n${ e }` );
|
|
console.red( `WTF? 'Network timeout' is small for your machine. file: ${ file } \n${ e }` );
|
|
- ++ failedScreenshots;
|
|
|
|
|
|
+ failedScreenshots.push( file );
|
|
continue;
|
|
continue;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -234,6 +214,7 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
attemptId = maxAttemptId;
|
|
attemptId = maxAttemptId;
|
|
await page.screenshot( { path: `./examples/screenshots/${ file }.png` } );
|
|
await page.screenshot( { path: `./examples/screenshots/${ file }.png` } );
|
|
|
|
+ printImage( png.sync.read( fs.readFileSync( `./examples/screenshots/${ file }.png` ) ), console );
|
|
console.green( `file: ${ file } generated` );
|
|
console.green( `file: ${ file } generated` );
|
|
|
|
|
|
|
|
|
|
@@ -260,7 +241,7 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
attemptId = maxAttemptId;
|
|
attemptId = maxAttemptId;
|
|
console.red( `ERROR! Image sizes does not match in file: ${ file }` );
|
|
console.red( `ERROR! Image sizes does not match in file: ${ file }` );
|
|
- ++ failedScreenshots;
|
|
|
|
|
|
+ failedScreenshots.push( file );
|
|
continue;
|
|
continue;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -280,7 +261,7 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
printImage( diff, console );
|
|
printImage( diff, console );
|
|
console.red( `ERROR! Diff wrong in ${ numFailedPixels.toFixed( 3 ) } of pixels in file: ${ file }` );
|
|
console.red( `ERROR! Diff wrong in ${ numFailedPixels.toFixed( 3 ) } of pixels in file: ${ file }` );
|
|
- ++ failedScreenshots;
|
|
|
|
|
|
+ failedScreenshots.push( file );
|
|
continue;
|
|
continue;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -294,8 +275,7 @@ const pup = puppeteer.launch( {
|
|
} else {
|
|
} else {
|
|
|
|
|
|
attemptId = maxAttemptId;
|
|
attemptId = maxAttemptId;
|
|
- console.red( `ERROR! Screenshot not exists: ${ file }` );
|
|
|
|
- ++ failedScreenshots;
|
|
|
|
|
|
+ console.null( `Warning! Screenshot not exists: ${ file }` );
|
|
continue;
|
|
continue;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -307,10 +287,19 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
/* Finish */
|
|
/* Finish */
|
|
|
|
|
|
- if ( failedScreenshots ) {
|
|
|
|
|
|
+ if ( failedScreenshots.length ) {
|
|
|
|
+
|
|
|
|
+ if ( failedScreenshots.length > 1 ) {
|
|
|
|
+
|
|
|
|
+ console.red( 'List of failed screenshots: ' + failedScreenshots.join(' ') );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ console.red( `If you sure that all is right, try to run \`npm run make-screenshot ${ failedScreenshots[ 0 ] }\`` );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- console.red( `TEST FAILED! ${ failedScreenshots } from ${ endId - beginId } screenshots not pass.` );
|
|
|
|
- process.exit( 1 );
|
|
|
|
|
|
+ console.red( `TEST FAILED! ${ failedScreenshots.length } from ${ endId - beginId } screenshots not pass.` );
|
|
|
|
|
|
} else if ( ! process.env.MAKE ) {
|
|
} else if ( ! process.env.MAKE ) {
|
|
|
|
|
|
@@ -318,6 +307,8 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- await browser.close();
|
|
|
|
|
|
+ browser.close();
|
|
|
|
+ server.close();
|
|
|
|
+ process.exit( failedScreenshots.length );
|
|
|
|
|
|
} );
|
|
} );
|