2021-06-07 03:09:53 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-03-12 02:12:25 +03:00
|
|
|
import { config as loadEnv } from 'dotenv';
|
|
|
|
loadEnv({ path: path.join(__dirname, '..', '..', '.env') });
|
|
|
|
|
2022-04-07 00:57:14 +03:00
|
|
|
import type { Config } from './stable-test-runner';
|
2022-03-01 00:41:30 +03:00
|
|
|
import * as path from 'path';
|
2021-06-07 03:09:53 +03:00
|
|
|
|
2022-03-01 00:41:30 +03:00
|
|
|
const outputDir = path.join(__dirname, '..', '..', 'test-results');
|
2021-06-07 03:09:53 +03:00
|
|
|
const config: Config = {
|
2021-06-09 01:52:08 +03:00
|
|
|
timeout: 30000,
|
2021-06-07 03:09:53 +03:00
|
|
|
forbidOnly: !!process.env.CI,
|
2022-06-24 01:55:12 +03:00
|
|
|
workers: process.env.CI ? 2 : undefined,
|
2021-06-17 02:05:30 +03:00
|
|
|
preserveOutput: process.env.CI ? 'failures-only' : 'always',
|
2022-12-07 02:46:19 +03:00
|
|
|
snapshotPathTemplate: '__screenshots__/{testFilePath}/{arg}{ext}',
|
2022-03-26 09:09:02 +03:00
|
|
|
projects: [
|
2022-04-30 02:05:08 +03:00
|
|
|
{
|
feat: implement a new image comparison function (#19166)
This patch implements a new image comparison function, codenamed
"ssim-cie94". The goal of the new comparison function is to cancel out
browser non-determenistic rendering.
To use the new comparison function:
```ts
await expect(page).toHaveScreenshot({
comparator: 'ssim-cie94',
});
```
As of Nov 30, 2022, we identified the following sources of
non-determenistic rendering for Chromium:
- Anti-aliasing for certain shapes might be different due to the
way skia rasterizes certain shapes.
- Color blending might be different on `x86` and `aarch64`
architectures.
The new function employs a few heuristics to fight these
differences.
Consider two non-equal image pixels `(r1, g1, b1)` and `(r2, g2, b2)`:
1. If the [CIE94] metric is less then 1.0, then we consider these pixels
**EQUAL**. (The value `1.0` is the [just-noticeable difference] for
[CIE94].). Otherwise, proceed to next step.
1. If all the 8 neighbors of the first pixel match its color, or
if the 8 neighbors of the second pixel match its color, then these
pixels are **DIFFERENT**. (In case of anti-aliasing, some of the
direct neighbors have to be blended up or down.) Otherwise, proceed
to next step.
1. If SSIM in some locality around the different pixels is more than
0.99, then consider this pixels to be **EQUAL**. Otherwise, mark them
as **DIFFERENT**. (Local SSIM for anti-aliased pixels turns out to be
very close to 1.0).
[CIE94]: https://en.wikipedia.org/wiki/Color_difference#CIE94
[just-noticeable difference]:
https://en.wikipedia.org/wiki/Just-noticeable_difference
2022-12-03 02:22:05 +03:00
|
|
|
name: 'playwright-test',
|
|
|
|
testDir: __dirname,
|
|
|
|
testIgnore: ['assets/**', 'stable-test-runner/**'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'image_tools',
|
|
|
|
testDir: path.join(__dirname, '../image_tools'),
|
|
|
|
testIgnore: [path.join(__dirname, '../fixtures/**')],
|
2022-04-30 02:05:08 +03:00
|
|
|
},
|
2021-11-04 01:26:18 +03:00
|
|
|
],
|
2022-03-01 00:41:30 +03:00
|
|
|
reporter: process.env.CI ? [
|
|
|
|
['dot'],
|
|
|
|
['json', { outputFile: path.join(outputDir, 'report.json') }],
|
|
|
|
] : [
|
|
|
|
['list']
|
|
|
|
],
|
2021-06-07 03:09:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|