@empiricalrun/test-gen 0.5.1 → 0.6.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.
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/scenarios/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/scenarios/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAiGpC,iBAAe,iBAAiB,CAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,QAAQ,EAAE,CAAA;CAAE,EAAE,CAAC,CAqBxD;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -9,6 +9,15 @@ const google_auth_library_1 = require("google-auth-library");
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const slugify_1 = __importDefault(require("slugify"));
|
|
11
11
|
const yaml_1 = require("yaml");
|
|
12
|
+
function isValidJSON(str) {
|
|
13
|
+
try {
|
|
14
|
+
JSON.parse(str);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
/**
|
|
13
22
|
* Method to update / add scenarios to the repo.
|
|
14
23
|
* @param path
|
|
@@ -79,6 +88,22 @@ async function generateScenarios(scenariosPath) {
|
|
|
79
88
|
if (scenariosPath.startsWith("https://docs.google.com/spreadsheets")) {
|
|
80
89
|
return await generateScenariosUsingGsheet(scenariosPath);
|
|
81
90
|
}
|
|
91
|
+
else if (isValidJSON(scenariosPath)) {
|
|
92
|
+
const config = JSON.parse(scenariosPath);
|
|
93
|
+
const specPath = `./tests/${config.group || "index"}.spec.ts`;
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
specPath,
|
|
97
|
+
scenarios: [
|
|
98
|
+
{
|
|
99
|
+
name: config.name,
|
|
100
|
+
steps: config.steps,
|
|
101
|
+
assert: config.assert,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}
|
|
82
107
|
else {
|
|
83
108
|
return await generateScenariosUsingYAML(scenariosPath);
|
|
84
109
|
}
|