Skip to content

Commit e46c79b

Browse files
committed
fix: runner tests
1 parent 462e1de commit e46c79b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+393
-399
lines changed

bin/codecept.js

Lines changed: 3 additions & 3 deletions
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.error('NodeJS >= 12 is required to run.');
34+
outputLib.output.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}`);
@@ -133,7 +133,7 @@ program.command('run [test]')
133133
.option('-R, --reporter <name>', 'specify the reporter to use')
134134
.option('-S, --sort', 'sort test files')
135135
.option('-b, --bail', 'bail after first test failure')
136-
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
136+
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
137137
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
138138
.option('-f, --fgrep <string>', 'only run tests containing <string>')
139139
.option('-i, --invert', 'inverts --grep and --fgrep matches')
@@ -231,7 +231,7 @@ program.command('run-rerun [test]')
231231
.option('-R, --reporter <name>', 'specify the reporter to use')
232232
.option('-S, --sort', 'sort test files')
233233
.option('-b, --bail', 'bail after first test failure')
234-
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
234+
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
235235
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
236236
.option('-f, --fgrep <string>', 'only run tests containing <string>')
237237
.option('-i, --invert', 'inverts --grep and --fgrep matches')

docs/hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const output = require('codeceptjs').output;
243243

244244
output.print('This is basic information');
245245
output.debug('This is debug information');
246-
output.log('This is verbose logging information');
246+
output.output.log('This is verbose logging information');
247247
```
248248
249249
### Container

docs/internal-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const output = require('codeceptjs').output;
191191

192192
output.print('This is basic information');
193193
output.debug('This is debug information');
194-
output.log('This is verbose logging information');
194+
output.output.log('This is verbose logging information');
195195
```
196196
197197
#### Test Object

lib/actor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Actor {
4040
if (!store.timeouts) return this;
4141

4242
event.dispatcher.prependOnceListener(event.step.before, (step) => {
43-
output.log(`Timeout to ${step}: ${timeout}s`);
43+
output.output.log(`Timeout to ${step}: ${timeout}s`);
4444
step.setTimeout(timeout * 1000, Step.TIMEOUT_ORDER.codeLimitTime);
4545
});
4646

lib/ai.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ class AiAssistant {
9191
} catch (err) {
9292
debug(err.response);
9393
output.print('');
94-
output.error(`OpenAI error: ${err.message}`);
95-
output.error(err?.response?.data?.error?.code);
96-
output.error(err?.response?.data?.error?.message);
94+
output.output.error(`OpenAI error: ${err.message}`);
95+
output.output.error(err?.response?.data?.error?.code);
96+
output.output.error(err?.response?.data?.error?.message);
9797
return '';
9898
}
9999
}

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Cli extends Base {
8585
codeceptjsEventDispatchersRegistered = true;
8686

8787
event.dispatcher.on(event.bddStep.started, (step) => {
88-
// output.output.stepShift = 2;
88+
output.output.stepShift = 2;
8989
output.output.step(step);
9090
});
9191

lib/codecept.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { existsSync, readFileSync } from 'fs';
22
import glob from 'glob';
3-
import fsPath, { resolve } from 'path';
3+
import fsPath, { resolve, dirname } from 'path';
44
import generated from '@codeceptjs/helper';
5+
import { fileURLToPath } from 'url';
6+
import {createRequire} from "node:module";
57
import container from './container.js';
68
import Config from './config.js';
79
import * as event from './event.js';
@@ -41,7 +43,8 @@ import listener01234 from './listener/timeout.js';
4143

4244
import listener012345 from './listener/exit.js';
4345

44-
const __dirname = fsPath.resolve('.');
46+
const __dirname = dirname(fileURLToPath(import.meta.url));
47+
const require = createRequire(import.meta.url);
4548

4649
/**
4750
* CodeceptJS runner
@@ -241,5 +244,5 @@ export default class Codecept {
241244
}
242245

243246
export function version() {
244-
return JSON.parse(readFileSync(`${__dirname}/package.json`, 'utf8')).version;
247+
return JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8')).version;
245248
}

lib/command/configMigrate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function (initPath) {
3131

3232
const configFile = path.join(testsPath, 'codecept.conf.js');
3333
if (fileExists(configFile)) {
34-
outputLib.output.error(`Config is already created at ${configFile}`);
34+
outputLib.output.output.error(`Config is already created at ${configFile}`);
3535
return;
3636
}
3737

lib/command/dryRun.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function printTests(files) {
5050
const figures = require('figures');
5151
const colors = require('chalk');
5252

53-
output.print(output.styles.debug(`Tests from ${global.codecept_dir}:`));
53+
output.print(output.output.styles.debug(`Tests from ${global.codecept_dir}:`));
5454
output.print();
5555

5656
const mocha = Container.mocha();
@@ -68,12 +68,12 @@ function printTests(files) {
6868
}
6969
const displayedSuites = process.env.grep ? filteredSuites : mocha.suite.suites;
7070
for (const suite of displayedSuites) {
71-
output.print(`${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${suite.tests.length} tests`);
71+
output.print(`${colors.white.bold(suite.title)} -- ${output.output.styles.log(suite.file || '')} -- ${suite.tests.length} tests`);
7272
numOfSuites++;
7373

7474
for (const test of suite.tests) {
7575
numOfTests++;
76-
output.print(` ${output.styles.scenario(figures.checkboxOff)} ${test.title}`);
76+
output.print(` ${output.output.styles.scenario(figures.checkboxOff)} ${test.title}`);
7777
}
7878
}
7979

lib/command/gherkin/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function (genPath) {
3131
output.print('--------------------------');
3232

3333
if (config.gherkin && config.gherkin.steps) {
34-
output.error('Gherkin is already initialized in this project. See `gherkin` section in the config');
34+
output.output.error('Gherkin is already initialized in this project. See `gherkin` section in the config');
3535
process.exit(1);
3636
}
3737

0 commit comments

Comments
 (0)