Skip to content

Commit f535d49

Browse files
committed
fix: more tests
1 parent 0cc967e commit f535d49

File tree

114 files changed

+474
-431
lines changed

Some content is hidden

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

114 files changed

+474
-431
lines changed

.eslintrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"arrow-parens": 0,
4545
"default-param-last": 0,
4646
"import/extensions": 0,
47-
"no-return-await": "off"
47+
"no-return-await": "off",
48+
"import/prefer-default-export": 0,
49+
"import/no-named-as-default-member": 0,
50+
"import/no-named-default": 0,
51+
"import/no-cycle": 0
4852
}
4953
}

bin/codecept.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
2-
import { program } from 'commander';
3-
import Codecept from '../lib/codecept.js';
2+
import { Command } from 'commander';
3+
const program = new Command();
4+
import { version } from '../lib/codecept.js';
45
import { print, error } from '../lib/output.js';
56
import { printError } from '../lib/command/utils.js';
67
import * as init from '../lib/command/init.js';
@@ -21,7 +22,7 @@ import * as info from '../lib/command/info.js';
2122

2223
const errorHandler = (fn) => async (...args) => {
2324
try {
24-
await fn(...args);
25+
await fn.default(...args);
2526
} catch (e) {
2627
printError(e);
2728
process.exitCode = 1;
@@ -37,7 +38,7 @@ if (process.versions.node && process.versions.node.split('.') && process.version
3738
}
3839

3940
program.usage('<command> [options]');
40-
program.version(Codecept.version());
41+
program.version(version());
4142

4243
program.command('init [path]')
4344
.description('Creates dummy config in current dir or [path]')
@@ -131,7 +132,7 @@ program.command('run [test]')
131132
.option('-R, --reporter <name>', 'specify the reporter to use')
132133
.option('-S, --sort', 'sort test files')
133134
.option('-b, --bail', 'bail after first test failure')
134-
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
135+
//.option('-d, --debug', "enable node's debugger, synonym for node --debug")
135136
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
136137
.option('-f, --fgrep <string>', 'only run tests containing <string>')
137138
.option('-i, --invert', 'inverts --grep and --fgrep matches')
@@ -229,7 +230,7 @@ program.command('run-rerun [test]')
229230
.option('-R, --reporter <name>', 'specify the reporter to use')
230231
.option('-S, --sort', 'sort test files')
231232
.option('-b, --bail', 'bail after first test failure')
232-
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
233+
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
233234
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
234235
.option('-f, --fgrep <string>', 'only run tests containing <string>')
235236
.option('-i, --invert', 'inverts --grep and --fgrep matches')

lib/actor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Step } from './step.js';
2-
import { MetaStep } from './step.js';
1+
import { Step, MetaStep } from './step.js';
32
import container from './container.js';
43
import { methodsOfObject } from './utils.js';
54
import recorder from './recorder.js';
65
import * as event from './event.js';
76
import { store } from './store.js';
8-
import output from './output.js';
7+
import * as output from './output.js';
98

109
/**
1110
* @interface

lib/ai.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Configuration, OpenAIApi } from 'openai';
22
import debug from 'debug';
3-
debug('codeceptjs:ai');
43
import config from './config.js';
5-
import output from './output.js';
4+
import * as output from './output.js';
65
import { removeNonInteractiveElements, minifyHtml, splitByChunks } from './html.js';
76

7+
debug('codeceptjs:ai');
8+
89
const defaultConfig = {
910
model: 'gpt-3.5-turbo-16k',
1011
temperature: 0.1,

lib/assert/empty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Assertion from '../assert.js';
22
import AssertionFailedError from './error.js';
33
import { template } from '../utils.js';
4-
import output from '../output.js';
4+
import * as output from '../output.js';
55

66
class EmptinessAssertion extends Assertion {
77
constructor(params) {

lib/assert/equal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Assertion from '../assert.js';
22
import AssertionFailedError from './error.js';
33
import { template } from '../utils.js';
4-
import output from '../output.js';
4+
import * as output from '../output.js';
55

66
class EqualityAssertion extends Assertion {
77
constructor(params) {

lib/assert/truth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Assertion from '../assert.js';
22
import AssertionFailedError from './error.js';
33
import { template } from '../utils.js';
4-
import output from '../output.js';
4+
import * as output from '../output.js';
55

66
class TruthAssertion extends Assertion {
77
constructor(params) {
@@ -31,7 +31,9 @@ class TruthAssertion extends Assertion {
3131
}
3232
}
3333

34+
export function truth(subject, type) {
35+
return new TruthAssertion({ subject, type });
36+
}
3437
export default {
3538
Assertion: TruthAssertion,
36-
truth: (subject, type) => new TruthAssertion({ subject, type }),
3739
};

lib/cli.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import mocha from 'mocha';
2-
3-
import ms from "ms";
4-
5-
import * as event from "./event.js";
6-
7-
import output from "./output.js";
8-
import AssertionFailedError from "./assert/error.js";
2+
import ms from 'ms';
3+
import * as event from './event.js';
4+
import * as output from './output.js';
5+
import AssertionFailedError from './assert/error.js';
6+
import * as Codecept from './codecept.js';
7+
import container from './container.js';
98

109
const { reporters: { Base } } = mocha;
1110

@@ -23,16 +22,15 @@ class Cli extends Base {
2322
if (opts.debug) level = 2;
2423
if (opts.verbose) level = 3;
2524
output.level(level);
26-
const version = require('./codecept.js').version();
25+
const version = Codecept.version();
2726
output.print(`CodeceptJS v${version} ${output.standWithUkraine()}`);
2827
output.print(`Using test root "${global.codecept_dir}"`);
2928

3029
const showSteps = level >= 1;
3130

3231
if (level >= 2) {
33-
const Containter = require('./container.js');
34-
output.print(output.styles.debug(`Helpers: ${Object.keys(Containter.helpers()).join(', ')}`));
35-
output.print(output.styles.debug(`Plugins: ${Object.keys(Containter.plugins()).join(', ')}`));
32+
output.print(output.styles.debug(`Helpers: ${Object.keys(container.helpers()).join(', ')}`));
33+
output.print(output.styles.debug(`Plugins: ${Object.keys(container.plugins()).join(', ')}`));
3634
}
3735

3836
runner.on('start', () => {

lib/codecept.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
import { existsSync, readFileSync } from 'fs';
22
import glob from 'glob';
3-
import fsPath from 'path';
4-
import { resolve } from 'path';
3+
import fsPath, { resolve } from 'path';
4+
import generated from '@codeceptjs/helper';
55
import container from './container.js';
66
import Config from './config.js';
77
import * as event from './event.js';
88
import runHook from './hooks.js';
9-
import output from './output.js';
9+
import * as output from './output.js';
1010
import { emptyFolder } from './utils.js';
11-
import path from "path";
12-
import generated from "@codeceptjs/helper";
1311
import * as index from './index.js';
1412

15-
import * as actor0 from "./actor.js";
13+
import * as actor0 from './actor.js';
1614

17-
import pause0 from "./pause.js";
15+
import pause0 from './pause.js';
1816

19-
import within0 from "./within.js";
17+
import within0 from './within.js';
2018

21-
import session0 from "./session.js";
19+
import session0 from './session.js';
2220

23-
import data from "./data/table.js";
21+
import data from './data/table.js';
2422

25-
import build from "./locator.js";
23+
import * as Build from './locator.js';
2624

2725
import secret from './secret.js';
2826

2927
// BDD
30-
import stepDefinitions from "./interfaces/bdd.js";
28+
import * as stepDefinitions from './interfaces/bdd.js';
3129

32-
import listener from "./listener/steps.js";
30+
import listener from './listener/steps.js';
3331

34-
import listener0 from "./listener/artifacts.js";
32+
import listener0 from './listener/artifacts.js';
3533

36-
import listener01 from "./listener/config.js";
34+
import listener01 from './listener/config.js';
3735

38-
import listener012 from "./listener/helpers.js";
36+
import listener012 from './listener/helpers.js';
3937

40-
import listener0123 from "./listener/retry.js";
38+
import listener0123 from './listener/retry.js';
4139

42-
import listener01234 from "./listener/timeout.js";
40+
import listener01234 from './listener/timeout.js';
4341

44-
import listener012345 from "./listener/exit.js";
42+
import listener012345 from './listener/exit.js';
4543

46-
const __dirname = path.resolve();
44+
const __dirname = fsPath.resolve('.');
4745

4846
/**
4947
* CodeceptJS runner
@@ -111,7 +109,7 @@ export default class Codecept {
111109
global.within = within0;
112110
global.session = session0;
113111
global.DataTable = data;
114-
global.locate = locator => new build(locator);
112+
global.locate = locator => new Build(locator);
115113
global.inject = container.support;
116114
global.share = container.share;
117115
global.secret = secret;
@@ -238,8 +236,8 @@ export default class Codecept {
238236
}
239237
});
240238
}
239+
}
241240

242-
static version() {
243-
return JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8')).version;
244-
}
241+
export function version() {
242+
return JSON.parse(readFileSync(`${__dirname}/package.json`, 'utf8')).version;
245243
}

lib/command/definitions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import fs from 'fs';
22
import path from 'path';
33
import { getConfig, getTestRoot } from './utils.js';
4-
import Codecept from '../../lib/codecept.js';
4+
import Codecept from '../codecept.js';
55
import container from '../container.js';
6-
import output from '../output.js';
7-
import plugin from "../plugin/standardActingHelpers.js";
6+
import * as output from '../output.js';
7+
import plugin from '../plugin/standardActingHelpers.js';
88

99
const actingHelpers = [...(plugin), 'REST'];
1010

0 commit comments

Comments
 (0)