@dev-blinq/cucumber_client 1.0.1380-dev → 1.0.1382-dev

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.
@@ -0,0 +1,37 @@
1
+ import {
2
+ After,
3
+ setDefaultTimeout,
4
+ Before,
5
+ AfterStep,
6
+ BeforeStep,
7
+ } from "@dev-blinq/cucumber-js";
8
+ import { closeContext, initContext, navigate, executeBrunoRequest, verifyFileExists } from "automation_model";
9
+ setDefaultTimeout(60 * 1000);
10
+
11
+ const url = null;
12
+
13
+ const elements = {};
14
+
15
+ let context = null;
16
+ Before(async function (scenario) {
17
+ context = await initContext(url, false, false, this);
18
+ await navigate(url);
19
+ await context.web.beforeScenario(this, scenario);
20
+ });
21
+ After(async function (scenario) {
22
+ await context.web.afterScenario(this, scenario);
23
+ await closeContext();
24
+ context = null;
25
+ });
26
+
27
+ BeforeStep(async function (step) {
28
+ if (context) {
29
+ await context.web.beforeStep(this, step);
30
+ }
31
+ });
32
+
33
+ AfterStep(async function (step) {
34
+ if (context) {
35
+ await context.web.afterStep(this, step);
36
+ }
37
+ });
@@ -2,53 +2,10 @@ import {
2
2
  Given,
3
3
  When,
4
4
  Then,
5
- After,
6
- setDefaultTimeout,
7
- Before,
8
5
  defineStep,
9
- AfterStep,
10
- BeforeStep,
11
6
  } from "@dev-blinq/cucumber-js";
12
7
  import { closeContext, initContext, navigate, executeBrunoRequest, verifyFileExists } from "automation_model";
13
8
  import path from "path";
14
- setDefaultTimeout(60 * 1000);
15
-
16
- const url = null;
17
-
18
- const elements = {};
19
-
20
- let context = null;
21
- Before(async function (scenario) {
22
- context = await initContext(url, false, false, this);
23
- await navigate(url);
24
- await context.web.beforeScenario(this, scenario);
25
- });
26
- After(async function (scenario) {
27
- await context.web.afterScenario(this, scenario);
28
- await closeContext();
29
- context = null;
30
- });
31
-
32
- BeforeStep(async function (step) {
33
- if (context) {
34
- await context.web.beforeStep(this, step);
35
- }
36
- });
37
-
38
- AfterStep(async function (step) {
39
- if (context) {
40
- await context.web.afterStep(this, step);
41
- }
42
- });
43
-
44
- /**
45
- * Load test data for a user
46
- * @param {string} user name of the user to load test data for
47
- * @protect
48
- */
49
- async function loadUserData(user) {
50
- await context.web.loadTestDataAsync("users", user, this);
51
- }
52
9
 
53
10
  /**
54
11
  * Verify text exsits in page
@@ -75,6 +75,12 @@ class ApiTest {
75
75
  const utilsTemplateFilePath = path.join(__dirname, "../../assets", "templates", "utils_template.txt");
76
76
  const utilsContent = readFileSync(utilsTemplateFilePath, "utf8");
77
77
  writeFileSync(utilsFilePath, utilsContent, "utf8");
78
+ const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
79
+ if (existsSync(hooksTemplateFilePath)) {
80
+ const hooksFilePath = path.join(stepDefinitionFolderPath, "_hooks.mjs");
81
+ const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
82
+ writeFileSync(hooksFilePath, hooksContent, "utf8");
83
+ }
78
84
  } catch (error) {
79
85
  console.log("error", error);
80
86
  }
@@ -82,6 +82,12 @@ class Project {
82
82
  const utilsContent = readFileSync(utilsPath, "utf8");
83
83
  const utilsFileName = this.stepsFolder + "/utils.mjs";
84
84
  writeFileSync(utilsFileName, utilsContent, "utf8");
85
+ const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
86
+ if (existsSync(hooksTemplateFilePath)) {
87
+ const hooksFilePath = path.join(this.stepsFolder, "_hooks.mjs");
88
+ const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
89
+ writeFileSync(hooksFilePath, hooksContent, "utf8");
90
+ }
85
91
  } catch (e) {
86
92
  logger.error("Error loading utils_template");
87
93
  }
@@ -116,6 +116,12 @@ export const getImplementedSteps = async (projectDir) => {
116
116
  const utilsContent = readFileSync(utilsTemplateFilePath, "utf8");
117
117
  //console.log({ utilsContent });
118
118
  writeFileSync(utilsFilePath, utilsContent, "utf8");
119
+ const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
120
+ if (existsSync(hooksTemplateFilePath)) {
121
+ const hooksFilePath = path.join(stepDefinitionFolderPath, "_hooks.mjs");
122
+ const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
123
+ writeFileSync(hooksFilePath, hooksContent, "utf8");
124
+ }
119
125
  } catch (error) {
120
126
  foundErrors.push({ error });
121
127
  }
@@ -372,6 +372,12 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir
372
372
  const utilsTemplateFilePath = path.join(__dirname, "../../assets", "templates", "utils_template.txt");
373
373
  const utilsContent = readFileSync(utilsTemplateFilePath, "utf8");
374
374
  writeFileSync(utilsFilePath, utilsContent, "utf8");
375
+ const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
376
+ if (existsSync(hooksTemplateFilePath)) {
377
+ const hooksFilePath = path.join(stepDefinitionFolderPath, "_hooks.mjs");
378
+ const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
379
+ writeFileSync(hooksFilePath, hooksContent, "utf8");
380
+ }
375
381
  const steps = scenario.steps;
376
382
 
377
383
  const stepsDefinitions = new StepsDefinitions(projectDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1380-dev",
3
+ "version": "1.0.1382-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "@cucumber/tag-expressions": "^6.1.1",
33
33
  "@dev-blinq/cucumber-js": "1.0.181-dev",
34
34
  "@faker-js/faker": "^8.1.0",
35
- "automation_model": "1.0.813-dev",
35
+ "automation_model": "1.0.814-dev",
36
36
  "axios": "^1.7.4",
37
37
  "chokidar": "^3.6.0",
38
38
  "create-require": "^1.1.1",