Skip to content

Commit ca534ee

Browse files
committed
fix: something
1 parent d7e1996 commit ca534ee

File tree

18 files changed

+68
-48
lines changed

18 files changed

+68
-48
lines changed

bin/codecept.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const errorHandler = (fn) => async (...args) => {
3131
};
3232

3333
if (process.versions.node && process.versions.node.split('.') && process.versions.node.split('.')[0] < 12) {
34-
outputLib.output.output.error('NodeJS >= 12 is required to run.');
34+
outputLib.output.error('NodeJS >= 12 is required to run.');
3535
outputLib.print();
3636
outputLib.print('Please upgrade your NodeJS engine');
3737
outputLib.print(`Current NodeJS version: ${process.version}`);

lib/ai.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Configuration, OpenAIApi } from 'openai';
2-
import debug from 'debug';
2+
import createDebugMessages from 'debug';
33
import config from './config.js';
44
import * as output from './output.js';
55
import { removeNonInteractiveElements, minifyHtml, splitByChunks } from './html.js';
66

7+
const debug = createDebugMessages('codeceptjs');
8+
79
debug('codeceptjs:ai');
810

911
const defaultConfig = {

lib/codecept.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ import listener01234 from './listener/timeout.js';
4343

4444
import listener012345 from './listener/exit.js';
4545

46+
import 'chai/register-assert.js';
47+
import 'chai/register-expect.js';
48+
4649
const __dirname = dirname(fileURLToPath(import.meta.url));
4750
const require = createRequire(import.meta.url);
4851

@@ -118,7 +121,7 @@ export default class Codecept {
118121
global.inject = container.support;
119122
global.share = container.share;
120123
global.secret = secret;
121-
global.codecept_debug = output.debug;
124+
global.codecept_debug = output.output.debug;
122125
global.codeceptjs = index; // load all objects
123126
global.Given = stepDefinitions.Given;
124127
global.When = stepDefinitions.When;

lib/container.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ function createHelpers(config) {
175175
// check if the helper is the built-in, use the require() syntax.
176176
if (moduleName.startsWith('./helper/')) {
177177
const __dirname = dirname(fileURLToPath(import.meta.url));
178-
HelperClass = importSync(path.resolve(__dirname, moduleName)).default;
178+
try {
179+
HelperClass = importSync(path.resolve(__dirname, moduleName)).default;
180+
} catch (e) {
181+
HelperClass = importSync(path.resolve(__dirname, moduleName));
182+
}
179183
} else {
180184
// check if the new syntax export default HelperName is used and loads the Helper, otherwise loads the module that used old syntax export = HelperName.
181185
HelperClass = importSync(path.resolve(moduleName)).default;

lib/event.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import debug from 'debug';
1+
import createDebugMessages from 'debug';
22

33
import events from 'events';
44
import * as output from './output.js';
55

6+
const debug = createDebugMessages('codeceptjs');
7+
68
debug('codeceptjs:event');
79

810
const dispatcher = new events.EventEmitter();

lib/helper/Expect.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { expect } from 'chai';
2-
import * as chai from 'chai';
31
import chai_json_schema from 'chai-json-schema';
42
import chai_match_pattern from 'chai-match-pattern';
53
import chai_exclude from 'chai-exclude';
64
import chai_string from 'chai-string';
5+
import { expect, use } from 'chai';
76
import * as output from '../output.js';
87

9-
chai.use(chai_string);
8+
use(chai_string);
109
// @ts-ignore
11-
chai.use(chai_exclude);
12-
chai.use(chai_match_pattern);
13-
chai.use(chai_json_schema);
10+
use(chai_exclude);
11+
use(chai_match_pattern);
12+
use(chai_json_schema);
1413

1514
/**
1615
* This helper allows performing assertions based on Chai.

lib/interfaces/gherkin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Gherkin from '@cucumber/gherkin';
22
import * as Messages from '@cucumber/messages';
33
import { Context, Suite, Test } from 'mocha';
44

5-
import debug from 'debug';
5+
import createDebugMessages from 'debug';
66

77
import { matchStep } from './bdd.js';
88
import * as event from '../event.js';
@@ -13,6 +13,8 @@ import transform from '../transform.js';
1313

1414
import translations0 from '../translation.js';
1515

16+
const debug = createDebugMessages('codeceptjs');
17+
1618
debug('codeceptjs:bdd');
1719

1820
const uuidFn = Messages.IdGenerator.uuid();

lib/listener/steps.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import debug from 'debug';
1+
import createDebugMessages from 'debug';
22
import * as event from '../event.js';
33
import { store } from '../store.js';
44
import * as output from '../output.js';
55

6+
const debug = createDebugMessages('codeceptjs');
7+
68
debug('codeceptjs:steps');
79

810
let currentTest;

lib/pause.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import colors from 'chalk';
22
import readline from 'readline';
33
import ora from 'ora-classic';
4-
import debug from 'debug';
4+
import createDebugMessages from 'debug';
55

66
import container from './container.js';
77
import history from './history.js';
@@ -12,6 +12,8 @@ import * as event from './event.js';
1212
import * as output from './output.js';
1313
import { methodsOfObject } from './utils.js';
1414

15+
const debug = createDebugMessages('codeceptjs');
16+
1517
debug('codeceptjs:pause');
1618

1719
// npm install colors

lib/plugin/autoLogin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileExists, isAsyncFunction } from '../utils.js';
44
import container from '../container.js';
55
import { store } from '../store.js';
66
import recorder from '../recorder.js';
7-
import { debug } from '../output.js';
7+
import * as output from '../output.js';
88

99
const defaultUser = {
1010
fetch: I => I.grabCookie(),
@@ -267,7 +267,7 @@ export default function (config) {
267267
} catch (err) {
268268
throw new Error(`Could not load session from ${fileName}\n${err}`);
269269
}
270-
debug(`Loaded user session for ${name}`);
270+
output.output.debug(`Loaded user session for ${name}`);
271271
}
272272
}
273273

@@ -288,11 +288,11 @@ export default function (config) {
288288

289289
const cookies = await userSession.fetch(I);
290290
if (!cookies) {
291-
debug('Cannot save user session with empty cookies from auto login\'s fetch method');
291+
output.output.debug('Cannot save user session with empty cookies from auto login\'s fetch method');
292292
return;
293293
}
294294
if (config.saveToFile) {
295-
debug(`Saved user session into file for ${name}`);
295+
output.output.debug(`Saved user session into file for ${name}`);
296296
fs.writeFileSync(path.join(global.output_dir, `${name}_session.json`), JSON.stringify(cookies));
297297
}
298298
store[`${name}_session`] = cookies;
@@ -309,12 +309,12 @@ export default function (config) {
309309
userSession.check(I, cookies);
310310
}
311311
recorder.session.catch((err) => {
312-
debug(`Failed auto login for ${name} due to ${err}`);
313-
debug('Logging in again');
312+
output.output.debug(`Failed auto login for ${name} due to ${err}`);
313+
output.output.debug('Logging in again');
314314
recorder.session.start('auto login');
315315
return loginAndSave().then(() => {
316316
recorder.add(() => recorder.session.restore('auto login'));
317-
recorder.catch(() => debug('continue'));
317+
recorder.catch(() => output.output.debug('continue'));
318318
}).catch((err) => {
319319
recorder.session.restore('auto login');
320320
recorder.session.restore('check login');

0 commit comments

Comments
 (0)