regressify 1.2.6 → 1.2.7

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.
@@ -1,3 +1,20 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ function getStorageState(stateName) {
5
+ const statePath = path.join(process.cwd(), 'states', `storage-states--${stateName}.json`);
6
+ if (fs.existsSync(statePath)) {
7
+ const json = fs.readFileSync(statePath, 'utf8');
8
+ return JSON.parse(json);
9
+ }
10
+ }
11
+
1
12
  module.exports = async (page, scenario, viewport, isReference, browserContext) => {
2
13
  await require('./loadCookies')(browserContext, scenario);
14
+
15
+ if (scenario.restore) {
16
+ console.log(logPrefix + 'restore:', scenario.restore);
17
+ const states = getStorageState(scenario.restore);
18
+ await browserContext.storageState(states);
19
+ }
3
20
  };
@@ -1,24 +1,8 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
1
  const autoScroll = require('../auto-scroll');
4
2
  const scrollTop = require('../scroll-top');
5
3
  const chalkImport = import('chalk').then((m) => m.default);
6
4
 
7
- function getStorageState(stateName) {
8
- const statePath = path.join(process.cwd(), 'states', `storage-states--${stateName}.json`);
9
- if (fs.existsSync(statePath)) {
10
- const json = fs.readFileSync(statePath, 'utf8');
11
- return JSON.parse(json);
12
- }
13
- }
14
-
15
5
  module.exports = async (page, scenario, viewport, isReference, browserContext) => {
16
- if (scenario.restore) {
17
- console.log(logPrefix + 'restore:', scenario.restore);
18
- const states = getStorageState(scenario.restore);
19
- await browserContext.storageState(states);
20
- }
21
-
22
6
  await require('./embedFiles')(scenario, page);
23
7
  await page.evaluate(autoScroll);
24
8
  const chalk = await chalkImport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",