Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
024ec5b
WIP
kobenguyent Feb 20, 2024
4e28312
fix: more UTs
kobenguyent Feb 20, 2024
0cc967e
fix: more tests
kobenguyent Feb 21, 2024
f535d49
fix: more tests
kobenguyent Feb 21, 2024
33ccd9b
fix: more tests
kobenguyent Feb 22, 2024
41e22d3
fix: unit tests
kobenguyent Feb 22, 2024
2b404b0
fix: unit tests
kobenguyent Feb 22, 2024
462e1de
fix: output module
kobenguyent Feb 23, 2024
e46c79b
fix: runner tests
kobenguyent Feb 23, 2024
82d892b
fix: more runner tests
kobenguyent Feb 23, 2024
1c790ee
fix: more runner tests
kobenguyent Feb 23, 2024
2f1cfe6
Merge branch '3.x' into migrate-to-esm
kobenguyent Mar 6, 2024
8115f4a
fix: MockServer_test.js
kobenguyent Mar 6, 2024
c09919c
fix: more tests and export __dirname
kobenguyent Mar 7, 2024
afd5245
fix: more test/unit
kobenguyent Mar 7, 2024
733de43
fix: tryTo plugin
kobenguyent Mar 7, 2024
5b1f101
fix: tryTo plugin
kobenguyent Mar 7, 2024
9bea75d
fix: tryTo plugin
kobenguyent Mar 7, 2024
d55aaed
fix: tryTo plugin
kobenguyent Mar 7, 2024
f4129b1
fix: fixDefFiles.js
kobenguyent Mar 7, 2024
81c103d
fix: bdd_test
kobenguyent Mar 11, 2024
ac57fea
merged with 3.x branch
kobenguyent Mar 30, 2024
37d4c21
try to fix plugin tests
kobenguyent Mar 30, 2024
35584c4
bump monocart coverage version
kobenguyent Mar 31, 2024
9860591
fix: conflicts
kobenguyent Apr 2, 2024
0601089
fix: failed UTs
kobenguyent Apr 2, 2024
7cb26c7
fix tests
kobenguyent Apr 8, 2024
1c8318f
fix: help_test.js
kobenguyent Apr 19, 2024
fb98821
fix some dry-run tests
kobenguyent Apr 19, 2024
2b62f7b
fix conflict
kobenguyent Sep 23, 2024
79f012b
fix: soft expect helper tests
kobenguyent Sep 23, 2024
a7e5a76
fix: screenshotOnFail tests
kobenguyent Sep 23, 2024
8e2fc37
fix: codepcept-js code and types
kobenguyent Sep 23, 2024
6f5f03b
fix: gherkin_test and scenario stale test
kobenguyent Sep 23, 2024
b5f9f3a
fix: actions, playwright, pw_test, stepbystep report, webapi
kobenguyent Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: more tests
  • Loading branch information
kobenguyent committed Feb 21, 2024
commit f535d492172d286685dc742e077f0d4f1db31ab9
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"arrow-parens": 0,
"default-param-last": 0,
"import/extensions": 0,
"no-return-await": "off"
"no-return-await": "off",
"import/prefer-default-export": 0,
"import/no-named-as-default-member": 0,
"import/no-named-default": 0,
"import/no-cycle": 0
}
}
13 changes: 7 additions & 6 deletions bin/codecept.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import { program } from 'commander';
import Codecept from '../lib/codecept.js';
import { Command } from 'commander';
const program = new Command();
import { version } from '../lib/codecept.js';
import { print, error } from '../lib/output.js';
import { printError } from '../lib/command/utils.js';
import * as init from '../lib/command/init.js';
Expand All @@ -21,7 +22,7 @@ import * as info from '../lib/command/info.js';

const errorHandler = (fn) => async (...args) => {
try {
await fn(...args);
await fn.default(...args);
} catch (e) {
printError(e);
process.exitCode = 1;
Expand All @@ -37,7 +38,7 @@ if (process.versions.node && process.versions.node.split('.') && process.version
}

program.usage('<command> [options]');
program.version(Codecept.version());
program.version(version());

program.command('init [path]')
.description('Creates dummy config in current dir or [path]')
Expand Down Expand Up @@ -131,7 +132,7 @@ program.command('run [test]')
.option('-R, --reporter <name>', 'specify the reporter to use')
.option('-S, --sort', 'sort test files')
.option('-b, --bail', 'bail after first test failure')
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
//.option('-d, --debug', "enable node's debugger, synonym for node --debug")
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
.option('-f, --fgrep <string>', 'only run tests containing <string>')
.option('-i, --invert', 'inverts --grep and --fgrep matches')
Expand Down Expand Up @@ -229,7 +230,7 @@ program.command('run-rerun [test]')
.option('-R, --reporter <name>', 'specify the reporter to use')
.option('-S, --sort', 'sort test files')
.option('-b, --bail', 'bail after first test failure')
.option('-d, --debug', "enable node's debugger, synonym for node --debug")
// .option('-d, --debug', "enable node's debugger, synonym for node --debug")
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
.option('-f, --fgrep <string>', 'only run tests containing <string>')
.option('-i, --invert', 'inverts --grep and --fgrep matches')
Expand Down
5 changes: 2 additions & 3 deletions lib/actor.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Step } from './step.js';
import { MetaStep } from './step.js';
import { Step, MetaStep } from './step.js';
import container from './container.js';
import { methodsOfObject } from './utils.js';
import recorder from './recorder.js';
import * as event from './event.js';
import { store } from './store.js';
import output from './output.js';
import * as output from './output.js';

/**
* @interface
Expand Down
5 changes: 3 additions & 2 deletions lib/ai.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Configuration, OpenAIApi } from 'openai';
import debug from 'debug';
debug('codeceptjs:ai');
import config from './config.js';
import output from './output.js';
import * as output from './output.js';
import { removeNonInteractiveElements, minifyHtml, splitByChunks } from './html.js';

debug('codeceptjs:ai');

const defaultConfig = {
model: 'gpt-3.5-turbo-16k',
temperature: 0.1,
Expand Down
2 changes: 1 addition & 1 deletion lib/assert/empty.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Assertion from '../assert.js';
import AssertionFailedError from './error.js';
import { template } from '../utils.js';
import output from '../output.js';
import * as output from '../output.js';

class EmptinessAssertion extends Assertion {
constructor(params) {
Expand Down
2 changes: 1 addition & 1 deletion lib/assert/equal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Assertion from '../assert.js';
import AssertionFailedError from './error.js';
import { template } from '../utils.js';
import output from '../output.js';
import * as output from '../output.js';

class EqualityAssertion extends Assertion {
constructor(params) {
Expand Down
6 changes: 4 additions & 2 deletions lib/assert/truth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Assertion from '../assert.js';
import AssertionFailedError from './error.js';
import { template } from '../utils.js';
import output from '../output.js';
import * as output from '../output.js';

class TruthAssertion extends Assertion {
constructor(params) {
Expand Down Expand Up @@ -31,7 +31,9 @@ class TruthAssertion extends Assertion {
}
}

export function truth(subject, type) {
return new TruthAssertion({ subject, type });
}
export default {
Assertion: TruthAssertion,
truth: (subject, type) => new TruthAssertion({ subject, type }),
};
20 changes: 9 additions & 11 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mocha from 'mocha';

import ms from "ms";

import * as event from "./event.js";

import output from "./output.js";
import AssertionFailedError from "./assert/error.js";
import ms from 'ms';
import * as event from './event.js';
import * as output from './output.js';
import AssertionFailedError from './assert/error.js';
import * as Codecept from './codecept.js';
import container from './container.js';

const { reporters: { Base } } = mocha;

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

const showSteps = level >= 1;

if (level >= 2) {
const Containter = require('./container.js');
output.print(output.styles.debug(`Helpers: ${Object.keys(Containter.helpers()).join(', ')}`));
output.print(output.styles.debug(`Plugins: ${Object.keys(Containter.plugins()).join(', ')}`));
output.print(output.styles.debug(`Helpers: ${Object.keys(container.helpers()).join(', ')}`));
output.print(output.styles.debug(`Plugins: ${Object.keys(container.plugins()).join(', ')}`));
}

runner.on('start', () => {
Expand Down
46 changes: 22 additions & 24 deletions lib/codecept.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
import { existsSync, readFileSync } from 'fs';
import glob from 'glob';
import fsPath from 'path';
import { resolve } from 'path';
import fsPath, { resolve } from 'path';
import generated from '@codeceptjs/helper';
import container from './container.js';
import Config from './config.js';
import * as event from './event.js';
import runHook from './hooks.js';
import output from './output.js';
import * as output from './output.js';
import { emptyFolder } from './utils.js';
import path from "path";
import generated from "@codeceptjs/helper";
import * as index from './index.js';

import * as actor0 from "./actor.js";
import * as actor0 from './actor.js';

import pause0 from "./pause.js";
import pause0 from './pause.js';

import within0 from "./within.js";
import within0 from './within.js';

import session0 from "./session.js";
import session0 from './session.js';

import data from "./data/table.js";
import data from './data/table.js';

import build from "./locator.js";
import * as Build from './locator.js';

import secret from './secret.js';

// BDD
import stepDefinitions from "./interfaces/bdd.js";
import * as stepDefinitions from './interfaces/bdd.js';

import listener from "./listener/steps.js";
import listener from './listener/steps.js';

import listener0 from "./listener/artifacts.js";
import listener0 from './listener/artifacts.js';

import listener01 from "./listener/config.js";
import listener01 from './listener/config.js';

import listener012 from "./listener/helpers.js";
import listener012 from './listener/helpers.js';

import listener0123 from "./listener/retry.js";
import listener0123 from './listener/retry.js';

import listener01234 from "./listener/timeout.js";
import listener01234 from './listener/timeout.js';

import listener012345 from "./listener/exit.js";
import listener012345 from './listener/exit.js';

const __dirname = path.resolve();
const __dirname = fsPath.resolve('.');

/**
* CodeceptJS runner
Expand Down Expand Up @@ -111,7 +109,7 @@ export default class Codecept {
global.within = within0;
global.session = session0;
global.DataTable = data;
global.locate = locator => new build(locator);
global.locate = locator => new Build(locator);
global.inject = container.support;
global.share = container.share;
global.secret = secret;
Expand Down Expand Up @@ -238,8 +236,8 @@ export default class Codecept {
}
});
}
}

static version() {
return JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8')).version;
}
export function version() {
return JSON.parse(readFileSync(`${__dirname}/package.json`, 'utf8')).version;
}
6 changes: 3 additions & 3 deletions lib/command/definitions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs';
import path from 'path';
import { getConfig, getTestRoot } from './utils.js';
import Codecept from '../../lib/codecept.js';
import Codecept from '../codecept.js';
import container from '../container.js';
import output from '../output.js';
import plugin from "../plugin/standardActingHelpers.js";
import * as output from '../output.js';
import plugin from '../plugin/standardActingHelpers.js';

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

Expand Down
2 changes: 1 addition & 1 deletion lib/command/dryRun.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getConfig, getTestRoot } from './utils.js';
import Config from '../config.js';
import Codecept from '../codecept.js';
import output from '../output.js';
import * as output from '../output.js';
import * as event from '../event.js';
import { store } from '../store.js';
import Container from '../container.js';
Expand Down
10 changes: 7 additions & 3 deletions lib/command/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import fs from 'fs';
import inquirer from 'inquirer';
import mkdirp from 'mkdirp';
import path from 'path';
import { fileExists, ucfirst, lcfirst, beautify } from '../utils.js';
import output from '../output.js';
import {
fileExists, ucfirst, lcfirst, beautify,
} from '../utils.js';
import * as output from '../output.js';
import generateDefinitions from './definitions.js';
import { getConfig, getTestRoot, safeFileWrite, readConfig } from './utils.js';
import {
getConfig, getTestRoot, safeFileWrite, readConfig,
} from './utils.js';

let extension = 'js';

Expand Down
6 changes: 4 additions & 2 deletions lib/command/gherkin/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import path from 'path';
import mkdirp from 'mkdirp';
import output from '../../output.js';
import * as output from '../../output.js';
import { fileExists } from '../../utils.js';
import { getConfig, getTestRoot, updateConfig, safeFileWrite } from '../utils.js';
import {
getConfig, getTestRoot, updateConfig, safeFileWrite,
} from '../utils.js';

const featureFile = `Feature: Business rules
In order to achieve my goals
Expand Down
2 changes: 1 addition & 1 deletion lib/command/gherkin/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import glob from 'glob';
import fsPath from 'path';
import { getConfig, getTestRoot } from '../utils.js';
import Codecept from '../../codecept.js';
import output from '../../output.js';
import * as output from '../../output.js';
import { matchStep } from '../../interfaces/bdd.js';

const uuidFn = Messages.IdGenerator.uuid();
Expand Down
2 changes: 1 addition & 1 deletion lib/command/gherkin/steps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getConfig, getTestRoot } from '../utils.js';
import Codecept from '../../codecept.js';
import output from '../../output.js';
import * as output from '../../output.js';
import { getSteps } from '../../interfaces/bdd.js';

export default function (genPath, options) {
Expand Down
9 changes: 5 additions & 4 deletions lib/command/info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import envinfo from 'envinfo';
import { getConfig, getTestRoot } from './utils.js';
import Codecept from '../codecept.js';
import output from '../output.js';
import * as codeceptInstance from '../codecept.js';
import * as output from '../output.js';

export default async function (path) {
const testsPath = getTestRoot(path);
Expand All @@ -11,7 +12,7 @@ export default async function (path) {

output.print('\n Environment information:-\n');
const info = {};
info.codeceptVersion = Codecept.version();
info.codeceptVersion = codeceptInstance.version();
info.nodeInfo = await envinfo.helpers.getNodeInfo();
info.osInfo = await envinfo.helpers.getOSInfo();
info.cpuInfo = await envinfo.helpers.getCPUInfo();
Expand All @@ -37,7 +38,7 @@ export default async function (path) {
output.print('***************************************');
}

export const getMachineInfo = async () => {
export async function getMachineInfo() {
const info = {
nodeInfo: await envinfo.helpers.getNodeInfo(),
osInfo: await envinfo.helpers.getOSInfo(),
Expand All @@ -59,4 +60,4 @@ export const getMachineInfo = async () => {
output.print('If you need more detailed info, just run this: npx codeceptjs info');
output.print('***************************************');
return info;
};
}
2 changes: 1 addition & 1 deletion lib/command/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileExists, beautify, installedLocally } from '../utils.js';
import { getTestRoot } from './utils.js';
import generateDefinitions from './definitions.js';
import { test as generateTest } from './generate.js';
import * as translations0 from "../../translations/index.js";
import * as translations0 from '../../translations/index.js';

const isLocal = installedLocally();

Expand Down
2 changes: 1 addition & 1 deletion lib/command/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import recorder from '../recorder.js';
import Codecept from '../codecept.js';
import Container from '../container.js';
import * as event from '../event.js';
import output from '../output.js';
import * as output from '../output.js';
import webHelpers from '../plugin/standardActingHelpers.js';

export default async function (path, options) {
Expand Down
2 changes: 1 addition & 1 deletion lib/command/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Codecept from '../codecept.js';
import container from '../container.js';
import { getParamsToString } from '../parser.js';
import { methodsOfObject } from '../utils.js';
import output from '../output.js';
import * as output from '../output.js';

export default function (path) {
const testsPath = getTestRoot(path);
Expand Down
1 change: 1 addition & 0 deletions lib/command/run-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as event from '../event.js';
import collection from './run-multiple/collection.js';
import { clearString, replaceValueDeep } from '../utils.js';
import { getConfig, getTestRoot, fail } from './utils.js';

const __dirname = path.resolve();

const runner = path.join(__dirname, '/../../bin/codecept.js');
Expand Down
2 changes: 1 addition & 1 deletion lib/command/run-multiple/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class Run {

export function createRun(name, config) {
return new Run(name, config);
};
}
Loading