regressify 1.1.26 → 1.2.1

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.
@@ -2,7 +2,9 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const chalkImport = import('chalk').then((m) => m.default);
4
4
 
5
- module.exports = async (currentPage, scenario) => {
5
+ module.exports = async (context) => {
6
+ const { currentPage, scenario, browserContext } = context;
7
+
6
8
  if (!scenario.actions) {
7
9
  return;
8
10
  }
@@ -170,5 +172,15 @@ module.exports = async (currentPage, scenario) => {
170
172
  await page.waitForSelector(action.wait);
171
173
  }
172
174
  }
175
+
176
+ if (action.persit) {
177
+ console.log(logPrefix + 'persit:', action.uncheck);
178
+ const states = await browserContext.storageState();
179
+ fs.writeFileSync(getStatePath(), JSON.stringify(states, null, 2));
180
+ }
173
181
  }
174
182
  };
183
+
184
+ function getStatePath(stateName) {
185
+ return process.cwd() + `/states/storage-states--${stateName}.json`;
186
+ }
@@ -1,4 +1,3 @@
1
1
  module.exports = async (page, scenario, viewport, isReference, browserContext) => {
2
- await require('./login-user')(browserContext, scenario);
3
2
  await require('./loadCookies')(browserContext, scenario);
4
3
  };
@@ -2,7 +2,17 @@ const autoScroll = require('../auto-scroll');
2
2
  const scrollTop = require('../scroll-top');
3
3
  const chalkImport = import('chalk').then((m) => m.default);
4
4
 
5
+ function getStatePath(stateName) {
6
+ return process.cwd() + `/states/storage-states--${stateName}.json`;
7
+ }
8
+
5
9
  module.exports = async (page, scenario, viewport, isReference, browserContext) => {
10
+ if (scenario.restore) {
11
+ console.log(logPrefix + 'restore:', action.restore);
12
+ const states = JSON.parse(getStatePath(), 'utf8');
13
+ await browserContext.storageState(states);
14
+ }
15
+
6
16
  await require('./embedFiles')(scenario, page);
7
17
  await page.evaluate(autoScroll);
8
18
  const chalk = await chalkImport;
@@ -20,7 +30,7 @@ module.exports = async (page, scenario, viewport, isReference, browserContext) =
20
30
  console.log(logPrefix + 'SCENARIO > ' + scenario.label);
21
31
 
22
32
  if (!!scenario.actions) {
23
- await require('./actions')(page, scenario);
33
+ await require('./actions')({ page, scenario, browserContext });
24
34
  } else {
25
35
  await require('./clickAndHoverHelper')(page, scenario);
26
36
  }
@@ -1,4 +1,3 @@
1
1
  module.exports = async (page, scenario, viewport, isReference, browserContext) => {
2
- await require('./login-user')(browserContext, scenario);
3
2
  await require('./loadCookies')(browserContext, scenario);
4
3
  };
@@ -160,6 +160,9 @@
160
160
  "noScrollTop": {
161
161
  "type": "boolean"
162
162
  },
163
+ "restore": {
164
+ "type": "string"
165
+ },
163
166
  "actions": {
164
167
  "type": "array",
165
168
  "items": {
@@ -182,6 +185,9 @@
182
185
  {
183
186
  "$ref": "#/definitions/InputFileAction"
184
187
  },
188
+ {
189
+ "$ref": "#/definitions/PersitAction"
190
+ },
185
191
  {
186
192
  "$ref": "#/definitions/PressAction"
187
193
  },
@@ -627,6 +633,28 @@
627
633
  "required": [
628
634
  "wait"
629
635
  ]
636
+ },
637
+ "PersitAction": {
638
+ "type": "object",
639
+ "additionalProperties": false,
640
+ "properties": {
641
+ "persit": {
642
+ "type": "string"
643
+ },
644
+ "frame": {
645
+ "oneOf": [
646
+ {
647
+ "type": "string"
648
+ },
649
+ {
650
+ "type": "array",
651
+ "items": {
652
+ "type": "string"
653
+ }
654
+ }
655
+ ]
656
+ }
657
+ }
630
658
  }
631
659
  }
632
660
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.1.26",
3
+ "version": "1.2.1",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",