@empiricalrun/test-gen 0.5.1 → 0.7.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,5 +1,17 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f4a2519: feat: add support for json string support for adding / updating tests using test-gen
8
+
9
+ ## 0.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 3e0e6d1: feat: add support for json string support for adding / updating tests using test-gen
14
+
3
15
  ## 0.5.1
4
16
 
5
17
  ### Patch Changes
@@ -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;AAiFpC,iBAAe,iBAAiB,CAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,QAAQ,EAAE,CAAA;CAAE,EAAE,CAAC,CAMxD;AAED,OAAO,EAAE,iBAAiB,EAAE,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,CAuBxD;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,8 +88,26 @@ async function generateScenarios(scenariosPath) {
79
88
  if (scenariosPath.startsWith("https://docs.google.com/spreadsheets")) {
80
89
  return await generateScenariosUsingGsheet(scenariosPath);
81
90
  }
82
- else {
91
+ else if (scenariosPath.endsWith(".yaml")) {
83
92
  return await generateScenariosUsingYAML(scenariosPath);
84
93
  }
94
+ else if (isValidJSON(atob(scenariosPath))) {
95
+ const str = atob(scenariosPath);
96
+ const config = JSON.parse(str);
97
+ const specPath = `./tests/${config.group || "index"}.spec.ts`;
98
+ return [
99
+ {
100
+ specPath,
101
+ scenarios: [
102
+ {
103
+ name: config.name,
104
+ steps: config.steps,
105
+ assert: config.assert,
106
+ },
107
+ ],
108
+ },
109
+ ];
110
+ }
111
+ throw Error("Invalid path for test scenarios");
85
112
  }
86
113
  exports.generateScenarios = generateScenarios;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"