@brillout/test-e2e 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,18 +12,14 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
14
14
|
const expect_1 = require("./chai/expect");
|
|
15
|
-
async function testScreenshotFixture() {
|
|
16
|
-
const
|
|
15
|
+
async function testScreenshotFixture({ screenshotFixturePath, } = {}) {
|
|
16
|
+
const pngPaths = getPngPaths();
|
|
17
|
+
const pngFixturPath = screenshotFixturePath || pngPaths.pngFixturPath;
|
|
17
18
|
if (!fs_1.default.existsSync(pngFixturPath)) {
|
|
18
19
|
const pngActual = await takeScreenshot();
|
|
19
20
|
const fileContent = pngjs_1.PNG.sync.write(pngActual);
|
|
20
21
|
fs_1.default.writeFileSync(pngFixturPath, fileContent);
|
|
21
|
-
|
|
22
|
-
throw new Error([
|
|
23
|
-
'Screenshot fixture missing. Screenshot fixture created at following paths:',
|
|
24
|
-
` - ${pngFixturPath}`,
|
|
25
|
-
` - ${pngExpectPath}`,
|
|
26
|
-
].join('\n'));
|
|
22
|
+
throw new Error(`Screenshot fixture missing. Screenshot fixture created at ${pngFixturPath}. You can now re-run the test and the screenshot fixture test will pass.`);
|
|
27
23
|
}
|
|
28
24
|
const pngExpect = pngjs_1.PNG.sync.read(fs_1.default.readFileSync(pngFixturPath));
|
|
29
25
|
const pngActual = await takeScreenshot();
|
|
@@ -36,6 +32,7 @@ async function testScreenshotFixture() {
|
|
|
36
32
|
(0, expect_1.expect)(numDiffPixels).toBe(0);
|
|
37
33
|
}
|
|
38
34
|
catch (err) {
|
|
35
|
+
const { pngExpectPath, pngActualPath, pngDifferPath } = pngPaths;
|
|
39
36
|
{
|
|
40
37
|
console.log('Actual image written at', pngActualPath);
|
|
41
38
|
fs_1.default.writeFileSync(pngActualPath, pngjs_1.PNG.sync.write(pngActual));
|