regressify 1.1.26 → 1.2.0
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 (
|
|
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,21 @@ 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
|
+
}
|
|
181
|
+
|
|
182
|
+
if (action.restore) {
|
|
183
|
+
console.log(logPrefix + 'restore:', action.restore);
|
|
184
|
+
const states = JSON.parse(getStatePath(), 'utf8');
|
|
185
|
+
await browserContext.storageState(states);
|
|
186
|
+
}
|
|
173
187
|
}
|
|
174
188
|
};
|
|
189
|
+
|
|
190
|
+
function getStatePath(stateName) {
|
|
191
|
+
return process.cwd() + `/states/storage-states--${stateName}.json`;
|
|
192
|
+
}
|
|
@@ -20,7 +20,7 @@ module.exports = async (page, scenario, viewport, isReference, browserContext) =
|
|
|
20
20
|
console.log(logPrefix + 'SCENARIO > ' + scenario.label);
|
|
21
21
|
|
|
22
22
|
if (!!scenario.actions) {
|
|
23
|
-
await require('./actions')(page, scenario);
|
|
23
|
+
await require('./actions')({ page, scenario, browserContext });
|
|
24
24
|
} else {
|
|
25
25
|
await require('./clickAndHoverHelper')(page, scenario);
|
|
26
26
|
}
|
package/common/test-schema.json
CHANGED
|
@@ -627,6 +627,50 @@
|
|
|
627
627
|
"required": [
|
|
628
628
|
"wait"
|
|
629
629
|
]
|
|
630
|
+
},
|
|
631
|
+
"PersitAction": {
|
|
632
|
+
"type": "object",
|
|
633
|
+
"additionalProperties": false,
|
|
634
|
+
"properties": {
|
|
635
|
+
"persit": {
|
|
636
|
+
"type": "string"
|
|
637
|
+
},
|
|
638
|
+
"frame": {
|
|
639
|
+
"oneOf": [
|
|
640
|
+
{
|
|
641
|
+
"type": "string"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"type": "array",
|
|
645
|
+
"items": {
|
|
646
|
+
"type": "string"
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
"RestoreAction": {
|
|
654
|
+
"type": "object",
|
|
655
|
+
"additionalProperties": false,
|
|
656
|
+
"properties": {
|
|
657
|
+
"restore": {
|
|
658
|
+
"type": "string"
|
|
659
|
+
},
|
|
660
|
+
"frame": {
|
|
661
|
+
"oneOf": [
|
|
662
|
+
{
|
|
663
|
+
"type": "string"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"type": "array",
|
|
667
|
+
"items": {
|
|
668
|
+
"type": "string"
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
}
|
|
630
674
|
}
|
|
631
675
|
}
|
|
632
676
|
}
|