Skip to content

Commit 2b404b0

Browse files
committed
fix: unit tests
1 parent 41e22d3 commit 2b404b0

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"import/prefer-default-export": 0,
4949
"import/no-named-as-default-member": 0,
5050
"import/no-named-default": 0,
51-
"import/no-cycle": 0
51+
"import/no-cycle": 0,
52+
"prefer-const": "off",
53+
"no-import-assign": 0
5254
}
5355
}

bin/codecept.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env node
22
import { Command } from 'commander';
3-
const program = new Command();
43
import { version } from '../lib/codecept.js';
54
import { print, error } from '../lib/output.js';
65
import { printError } from '../lib/command/utils.js';
@@ -20,6 +19,8 @@ import * as rerun from '../lib/command/run-rerun.js';
2019
import * as dryRun from '../lib/command/dryRun.js';
2120
import * as info from '../lib/command/info.js';
2221

22+
const program = new Command();
23+
2324
const errorHandler = (fn) => async (...args) => {
2425
try {
2526
await fn.default(...args);
@@ -132,7 +133,7 @@ program.command('run [test]')
132133
.option('-R, --reporter <name>', 'specify the reporter to use')
133134
.option('-S, --sort', 'sort test files')
134135
.option('-b, --bail', 'bail after first test failure')
135-
//.option('-d, --debug', "enable node's debugger, synonym for node --debug")
136+
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
136137
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
137138
.option('-f, --fgrep <string>', 'only run tests containing <string>')
138139
.option('-i, --invert', 'inverts --grep and --fgrep matches')
@@ -230,7 +231,7 @@ program.command('run-rerun [test]')
230231
.option('-R, --reporter <name>', 'specify the reporter to use')
231232
.option('-S, --sort', 'sort test files')
232233
.option('-b, --bail', 'bail after first test failure')
233-
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
234+
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
234235
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
235236
.option('-f, --fgrep <string>', 'only run tests containing <string>')
236237
.option('-i, --invert', 'inverts --grep and --fgrep matches')

lib/cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as output from './output.js';
55
import AssertionFailedError from './assert/error.js';
66
import * as Codecept from './codecept.js';
77
import container from './container.js';
8+
import {stepShift} from "./output.js";
89

910
const { reporters: { Base } } = mocha;
1011

@@ -85,7 +86,7 @@ class Cli extends Base {
8586
codeceptjsEventDispatchersRegistered = true;
8687

8788
event.dispatcher.on(event.bddStep.started, (step) => {
88-
output.stepShift = 2;
89+
// output.stepShift = 2;
8990
output.step(step);
9091
});
9192

lib/container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function getSupportObject(config, name) {
318318
return module;
319319
}
320320

321-
function loadGherkinSteps(paths) {
321+
export function loadGherkinSteps(paths) {
322322
// @ts-ignore
323323
global.Before = fn => event.dispatcher.on(event.test.started, fn);
324324
// @ts-ignore

lib/output.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ let outputProcess = '';
1616
let newline = true;
1717
/** @type {number} */
1818
// eslint-disable-next-line import/no-mutable-exports
19-
export const stepShift = 0;
19+
let stepShift = 0;
2020
// eslint-disable-next-line import/no-mutable-exports
21-
export const spaceShift = 0;
21+
let spaceShift = 0;
22+
export { stepShift, spaceShift };
23+
2224

2325
/**
2426
* Print error
@@ -144,7 +146,7 @@ export const suite = {
144146
print(`${colors.bold(suite.title)} --`);
145147
if (suite.comment) print(suite.comment);
146148
},
147-
}
149+
};
148150

149151
/** @namespace */
150152
export const test = {
@@ -172,7 +174,7 @@ export const test = {
172174
skipped(test) {
173175
print(` ${colors.yellow.bold('S')} ${test.title}`);
174176
},
175-
}
177+
};
176178

177179
/** @namespace */
178180
export const scenario = {
@@ -196,7 +198,7 @@ export const scenario = {
196198
print(` ${colors.red.bold(`${figures.cross} FAILED`)} ${colors.grey(`in ${test.duration}ms`)}`);
197199
print();
198200
},
199-
}
201+
};
200202

201203
/**
202204
* @param {number} passed

test/data/sandbox/features/step_definitions/my_other_steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const I = actor();
3+
const { I } = inject();
44

55
Given('I have products in my cart', (table) => { // eslint-disable-line
66
for (const id in table.rows) {

0 commit comments

Comments
 (0)