regressify 1.2.6 → 1.2.8
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,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const YAML = require('js-yaml');
|
|
3
4
|
const chalkImport = import('chalk').then((m) => m.default);
|
|
4
5
|
|
|
5
6
|
module.exports = async (context) => {
|
|
@@ -182,11 +183,12 @@ module.exports = async (context) => {
|
|
|
182
183
|
};
|
|
183
184
|
|
|
184
185
|
function setStorageState(stateName, states) {
|
|
185
|
-
const statePath = path.join(process.cwd(), 'states',
|
|
186
|
+
const statePath = path.join(process.cwd(), 'states', `${stateName}.yaml`);
|
|
186
187
|
const parentDir = path.dirname(statePath);
|
|
187
188
|
if (!fs.existsSync(parentDir)) {
|
|
188
189
|
fs.mkdirSync(parentDir, { recursive: true });
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
const yaml = YAML.dump(states, { lineWidth: -1, noCompatMode: true });
|
|
193
|
+
fs.writeFileSync(yaml, JSON.stringify(states, null, 2));
|
|
192
194
|
}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const YAML = require('js-yaml');
|
|
4
|
+
|
|
5
|
+
function getStorageState(stateName) {
|
|
6
|
+
const statePath = path.join(process.cwd(), 'states', `${stateName}.yaml`);
|
|
7
|
+
if (fs.existsSync(statePath)) {
|
|
8
|
+
const yaml = fs.readFileSync(statePath, 'utf8');
|
|
9
|
+
return YAML.load(json);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
1
13
|
module.exports = async (page, scenario, viewport, isReference, browserContext) => {
|
|
2
14
|
await require('./loadCookies')(browserContext, scenario);
|
|
15
|
+
|
|
16
|
+
if (scenario.restore) {
|
|
17
|
+
console.log(logPrefix + 'restore:', scenario.restore);
|
|
18
|
+
const states = getStorageState(scenario.restore);
|
|
19
|
+
await browserContext.storageState(states);
|
|
20
|
+
}
|
|
3
21
|
};
|
|
@@ -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;
|