Skip to content

Commit a0e6e66

Browse files
Add custom setup and ignore snapshot files.
1 parent 8956386 commit a0e6e66

30 files changed

Lines changed: 229 additions & 202 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ wp-tests-config.php
8080
/docker-compose.override.yml
8181

8282
# Visual regression test diffs
83-
tests/e2e/specs/__image_snapshots__/__diff_output__
83+
tests/visual-regression/specs/__image_snapshots__

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
"test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit",
170170
"test:php-composer": "node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit",
171171
"test:e2e": "node ./tests/e2e/run-tests.js",
172+
"test:visual": "node ./tests/visual-regression/run-tests.js",
172173
"wp-packages-update": "wp-scripts packages-update"
173174
}
174175
}

tests/e2e/config/bootstrap.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { get } from 'lodash';
2-
import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
3-
42
import {
53
clearLocalStorage,
64
enablePageDialogAccept,
@@ -35,14 +33,6 @@ const pageEvents = [];
3533
// The Jest timeout is increased because these tests are a bit slow
3634
jest.setTimeout( PUPPETEER_TIMEOUT || 100000 );
3735

38-
const toMatchImageSnapshot = configureToMatchImageSnapshot( {
39-
dumpDiffToConsole: true,
40-
failureThresholdType: 'percent',
41-
failureThreshold: 3,
42-
} );
43-
44-
// Extend Jest's "expect" with image snapshot functionality.
45-
expect.extend( { toMatchImageSnapshot } );
4636

4737
/**
4838
* Adds an event listener to the page to handle additions of page event
@@ -114,11 +104,7 @@ function observeConsoleLogging() {
114104
// correctly. Instead, the logic here synchronously inspects the
115105
// internal object shape of the JSHandle to find the error text. If it
116106
// cannot be found, the default text value is used instead.
117-
text = get(
118-
message.args(),
119-
[ 0, '_remoteObject', 'description' ],
120-
text
121-
);
107+
text = get( message.args(), [ 0, '_remoteObject', 'description' ], text );
122108

123109
// Disable reason: We intentionally bubble up the console message
124110
// which, unless the test explicitly anticipates the logging via

0 commit comments

Comments
 (0)