Skip to content

Commit

Permalink
Fix some custom-tests snapshots normalizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Dec 13, 2024
1 parent 19214e7 commit 4585e2a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/qit-self-test-custom-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: imagick
ini-values: sys_temp_dir=${{ github.workspace }}/tmp

- name: Composer install
Expand Down
9 changes: 0 additions & 9 deletions _tests/custom_tests/tests/RunE2ETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,6 @@ public function test_playwright_config_override() {

$output = $this->normalize_scaffolded_test_run_output( $output );

// "Loading environment config from override parameter /tmp/qit-env-97d237784cddc7ec1341113ca364110d.json..." Normalize "97d237784cddc7ec1341113ca364110d".
$output = preg_replace( '/qit-env-[a-f0-9]{32}/', 'qit-env-<hash>', $output );

// "Slow test file: [woocommerce-amazon-s3-storage-local] › woocommerce-amazon-s3-storage/local/example.spec.js (7.1s)" Normalize "7.1s".
$output = preg_replace( '/\d+\.\d+s/', '<time>s', $output );

// Sometimes, for some reason, this has some spaces. "Consider splitting slow test files to speed up parallel execution"
$output = preg_replace( '#\s+Consider#', "\nConsider", $output );

$this->assertMatchesNormalizedSnapshot( $output );
}

Expand Down
1 change: 1 addition & 0 deletions _tests/custom_tests/tests/Traits/SnapshotHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function assertMatchesNormalizedSnapshot( string $actual, ?\Spatie\Snapsh
$actual = str_replace( rtrim( sys_get_temp_dir(), '/' ) . '/', '/tmp-normalized/', $actual );
$actual = str_replace( '/tmp/', '/tmp-normalized/', $actual );
$actual = preg_replace( '/qit-results-[a-z0-9]+/', 'qit-results-normalizedid', $actual );
$actual = preg_replace( '/qit-env-[a-f0-9]{32}\.json/', 'qit-env-<hash>.json', $actual );

if ( empty( getenv( 'TEST_TOKEN' ) ) ) {
$actual = preg_replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Running E2E Tests
Running 3 tests using 1 worker
✓ 1 [setup] Amazon S3 Storage (Shell) › scripts/bash.js:4:5 › Bash Script (TIME)
✓ 2 [setup] Amazon S3 Storage (JS) › woocommerce-amazon-s3-storage/local/bootstrap/setup.js:11:5 › Isolated Setup (TIME)
✓ 3 [test] Amazon S3 Storage (Run) › woocommerce-amazon-s3-storage/local/example.spec.js:9:5 › I can see my plugin menu (<time>s)
Slow test file: [test] Amazon S3 Storage (Run) › woocommerce-amazon-s3-storage/local/example.spec.js (<time>s)
✓ 3 [test] Amazon S3 Storage (Run) › woocommerce-amazon-s3-storage/local/example.spec.js:9:5 › I can see my plugin menu (TIME)
Slow test file: [test] Amazon S3 Storage (Run) › woocommerce-amazon-s3-storage/local/example.spec.js (TIME)
Slow test file: [setup] Amazon S3 Storage (Shell) › scripts/bash.js (TIME)
Slow test file: [setup] Amazon S3 Storage (JS) › woocommerce-amazon-s3-storage/local/bootstrap/setup.js (TIME)
Consider splitting slow test files to speed up parallel execution
Expand Down

0 comments on commit 4585e2a

Please sign in to comment.