@dev-blinq/cucumber_client 1.0.1335-dev → 1.0.1336-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.
@@ -215,7 +215,7 @@ export class BVTRecorder {
215
215
  this.pageSet = new Set();
216
216
  this.lastKnownUrlPath = "";
217
217
  // TODO: what is world?
218
- this.world = { attach: () => {} };
218
+ this.world = { attach: () => { } };
219
219
  this.shouldTakeScreenshot = true;
220
220
  this.watcher = null;
221
221
  }
@@ -324,7 +324,7 @@ export class BVTRecorder {
324
324
  process.env.CDP_LISTEN_PORT = this.#remoteDebuggerPort;
325
325
 
326
326
  this.stepRunner.setRemoteDebugPort(this.#remoteDebuggerPort);
327
- this.world = { attach: () => {} };
327
+ this.world = { attach: () => { } };
328
328
 
329
329
  const ai_config_file = path.join(this.projectDir, "ai_config.json");
330
330
  let ai_config = {};
@@ -730,7 +730,7 @@ export class BVTRecorder {
730
730
  }
731
731
  async closeBrowser() {
732
732
  delete process.env.TEMP_RUN;
733
- await this.watcher.close().then(() => {});
733
+ await this.watcher.close().then(() => { });
734
734
  this.watcher = null;
735
735
  this.previousIndex = null;
736
736
  this.previousHistoryLength = null;
@@ -821,6 +821,10 @@ export class BVTRecorder {
821
821
  this.timerId = timerId;
822
822
  }
823
823
  async runStep({ step, parametersMap, tags, isFirstStep, listenNetwork }, options) {
824
+ const {
825
+ skipAfter = true,
826
+ skipBefore = !isFirstStep,
827
+ } = options || {};
824
828
  const _env = {
825
829
  TOKEN: this.TOKEN,
826
830
  TEMP_RUN: true,
@@ -851,7 +855,10 @@ export class BVTRecorder {
851
855
  tags,
852
856
  },
853
857
  this.bvtContext,
854
- options ? { ...options, skipBefore: !isFirstStep } : { skipBefore: !isFirstStep }
858
+ {
859
+ skipAfter,
860
+ skipBefore,
861
+ }
855
862
  );
856
863
  await this.revertMode();
857
864
  return { info };
@@ -1145,6 +1152,47 @@ export class BVTRecorder {
1145
1152
  return false;
1146
1153
  }
1147
1154
  }
1155
+ async initExecution({ tags = [] }) {
1156
+ // run before hooks
1157
+ const noopStep = {
1158
+ text: "Noop",
1159
+ isImplemented: true,
1160
+ };
1161
+ await this.runStep(
1162
+ {
1163
+ step: noopStep,
1164
+ parametersMap: {},
1165
+ tags,
1166
+ },
1167
+ {
1168
+ skipBefore: false,
1169
+ skipAfter: true,
1170
+ }
1171
+ );
1172
+ }
1173
+ async cleanupExecution({ tags = [] }) {
1174
+ // run after hooks
1175
+ const noopStep = {
1176
+ text: "Noop",
1177
+ isImplemented: true,
1178
+ };
1179
+ await this.runStep(
1180
+ {
1181
+ step: noopStep,
1182
+ parametersMap: {},
1183
+ tags,
1184
+ },
1185
+ {
1186
+ skipBefore: true,
1187
+ skipAfter: false,
1188
+ }
1189
+ );
1190
+ }
1191
+ async resetExecution({ tags = [] }) {
1192
+ // run after hooks followed by before hooks
1193
+ await this.runAfterHooks({ tags });
1194
+ await this.runBeforeHooks({ tags });
1195
+ }
1148
1196
  }
1149
1197
 
1150
1198
  const parseFeatureFile = (featureFilePath) => {
@@ -275,6 +275,15 @@ const init = ({ envName, projectDir, roomId, TOKEN }) => {
275
275
  "recorderWindow.getNetworkEvents": async (input) => {
276
276
  return await recorder.getNetworkEvents(input);
277
277
  },
278
+ "recorderWindow.initExecution": async (input) => {
279
+ return await recorder.initExecution(input);
280
+ },
281
+ "recorderWindow.cleanupExecution": async (input) => {
282
+ return await recorder.cleanupExecution(input);
283
+ },
284
+ "recorderWindow.resetExecution": async (input) => {
285
+ return await recorder.resetExecution(input);
286
+ },
278
287
  });
279
288
  socket.on("targetBrowser.command.event", async (input) => {
280
289
  return recorder.onAction(input);
@@ -79,11 +79,7 @@ export class BVTStepRunner {
79
79
  }
80
80
 
81
81
  executeStepRemote = async ({ feature_file_path, scenario, tempFolderPath, stepText }, options) => {
82
- if (!options) {
83
- options = {
84
- skipAfter: true,
85
- };
86
- }
82
+ const { skipAfter = true, skipBefore = true } = options || {};
87
83
  const environment = {
88
84
  ...process.env,
89
85
  };
@@ -109,11 +105,18 @@ export class BVTStepRunner {
109
105
  // console.log("step", step.pattern);
110
106
  // });
111
107
 
112
- if (options.skipAfter) {
108
+ support.afterTestRunHookDefinitions = [];
109
+ if (skipAfter) {
113
110
  // ignore afterAll/after hooks
114
111
  support.afterTestCaseHookDefinitions = [];
115
- support.afterTestRunHookDefinitions = [];
116
112
  }
113
+ if (skipBefore) {
114
+ // ignore beforeAll/before hooks
115
+ support.beforeTestCaseHookDefinitions = support.beforeTestCaseHookDefinitions.filter((hook) => {
116
+ return hook.uri.endsWith("utils.mjs");
117
+ });
118
+ }
119
+ support.beforeTestRunHookDefinitions = [];
117
120
 
118
121
  let errorMesssage = null;
119
122
  let info = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1335-dev",
3
+ "version": "1.0.1336-dev",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",