Skip to content

Removed chai depenency #4535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
eef33c5
refactored JSONResponse to not use chai
Oct 31, 2024
771232c
removed chai dependencies
Oct 31, 2024
a86706f
removed soft expect helper
Oct 31, 2024
a58b021
removed dep on chai in JSONResponse
Oct 31, 2024
89414aa
updated graphql server
Nov 1, 2024
4edba3e
Delete .github/workflows/expectHelper.yml
kobenguyent Nov 4, 2024
47722bd
Delete .github/workflows/softExpectHelper.yml
kobenguyent Nov 4, 2024
1a314d2
Update package.json
kobenguyent Nov 4, 2024
418514c
removed helper tests
Nov 4, 2024
518656c
fix: remove mock server helper (#4536)
kobenguyent Nov 4, 2024
fbe7a06
--no-verify
Nov 4, 2024
1ef110a
removed mock server test
Nov 4, 2024
8f12d16
changed the way expect helper is loaded
Nov 4, 2024
ccb3d7f
loading expect helper form package
Nov 5, 2024
126b2db
loading expect helper form package
Nov 5, 2024
a0d453f
updated expect version
Nov 5, 2024
8646b72
updated dockerfile to use latest playwright, removed npm i --force
Nov 5, 2024
c87a027
improved loading esm/cjs style modules
Nov 5, 2024
02b0f4b
improved loading esm/cjs style modules
Nov 5, 2024
51c3b3b
improved loading esm/cjs style modules
Nov 5, 2024
dbdd82a
improved loading esm/cjs style modules
Nov 5, 2024
de6b257
changed docker file
Nov 5, 2024
11bcd9e
updated expect helper
Nov 5, 2024
8c0ec87
fixed loading cjs helper
Nov 5, 2024
ac4da06
fix async loading of helper methods
Nov 5, 2024
7e4f493
Merge branch '3.x' into refactor/downgrade-chai-5
Nov 7, 2024
117aba6
removed chai dep, merged with 3.x
Dec 22, 2024
e4bbe2d
fixed failed tests
Dec 22, 2024
95f3825
fixed worker test
Dec 22, 2024
57f2ac0
fixed container issues
Dec 25, 2024
996ebdc
Merge branch '3.x' into refactor/downgrade-chai-5
DavertMik Dec 25, 2024
64d95ff
resolved dependencies
Dec 25, 2024
0a27b34
added proxies to resolve circular dependencies
Dec 27, 2024
1f54ace
added proxies to resolve circular dependencies
Dec 27, 2024
784904c
fixed printing metasteps
Dec 27, 2024
f6ca98c
fixed tests
Dec 27, 2024
31a0f1d
fixed tests
Dec 27, 2024
9a837dd
reverted change to ;
Dec 30, 2024
9eeb4e9
reverted change to ;
Dec 30, 2024
ce5bb28
reverted change to ;
Dec 30, 2024
59b5a74
fixed runner tests
Dec 31, 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
reverted change to ;
  • Loading branch information
DavertMik committed Dec 30, 2024
commit ce5bb2823f93551091844fd493bc7e91f3097e9c
14 changes: 7 additions & 7 deletions lib/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Actor {
limitTime(timeout) {
if (!store.timeouts) return this;

event.dispatcher.prependOnceListener(event.step.before, (step) => {
event.dispatcher.prependOnceListener(event.step.before, step => {
output.log(`Timeout to ${step}: ${timeout}s`);
step.setTimeout(timeout * 1000, Step.TIMEOUT_ORDER.codeLimitTime);
});
Expand Down Expand Up @@ -78,10 +78,10 @@ module.exports = function (obj = {}) {
const helpers = container.helpers();

// add methods from enabled helpers
Object.values(helpers).forEach((helper) => {
Object.values(helpers).forEach(helper => {
methodsOfObject(helper, 'Helper')
.filter((method) => method !== 'constructor' && method[0] !== '_')
.forEach((action) => {
.filter(method => method !== 'constructor' && method[0] !== '_')
.forEach(action => {
const actionAlias = translation.actionAliasFor(action);
if (!actor[action]) {
actor[action] = actor[actionAlias] = function () {
Expand All @@ -98,7 +98,7 @@ module.exports = function (obj = {}) {
});

// add translated custom steps from actor
Object.keys(obj).forEach((key) => {
Object.keys(obj).forEach(key => {
const actionAlias = translation.actionAliasFor(key);
if (!actor[actionAlias]) {
actor[actionAlias] = actor[key];
Expand All @@ -113,7 +113,7 @@ module.exports = function (obj = {}) {
});
// store.actor = actor;
// add custom steps from actor
Object.keys(obj).forEach((key) => {
Object.keys(obj).forEach(key => {
const ms = new MetaStep('I', key);
ms.setContext(actor);
actor[key] = ms.run.bind(ms, obj[key]);
Expand Down Expand Up @@ -156,7 +156,7 @@ function recordStep(step, args) {
event.emit(event.step.finished, step);
});

recorder.catchWithoutStop((err) => {
recorder.catchWithoutStop(err => {
step.status = 'failed';
step.endTime = Date.now();
event.emit(event.step.failed, step);
Expand Down
22 changes: 11 additions & 11 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class Cli extends Base {
console.log();
});

runner.on('suite', (suite) => {
runner.on('suite', suite => {
output.suite.started(suite);
});

runner.on('fail', (test) => {
runner.on('fail', test => {
if (test.ctx.currentTest) {
this.loadedTests.push(test.ctx.currentTest.uid);
}
Expand All @@ -50,7 +50,7 @@ class Cli extends Base {
output.test.failed(test);
});

runner.on('pending', (test) => {
runner.on('pending', test => {
if (test.parent && test.parent.pending) {
const suite = test.parent;
const skipInfo = suite.opts.skipInfo || {};
Expand All @@ -63,7 +63,7 @@ class Cli extends Base {
output.test.skipped(test);
});

runner.on('pass', (test) => {
runner.on('pass', test => {
if (showSteps && test.steps) {
return output.scenario.passed(test);
}
Expand All @@ -72,7 +72,7 @@ class Cli extends Base {
});

if (showSteps) {
runner.on('test', (test) => {
runner.on('test', test => {
currentMetaStep = [];
if (test.steps) {
output.test.started(test);
Expand All @@ -82,12 +82,12 @@ class Cli extends Base {
if (!codeceptjsEventDispatchersRegistered) {
codeceptjsEventDispatchersRegistered = true;

event.dispatcher.on(event.bddStep.started, (step) => {
event.dispatcher.on(event.bddStep.started, step => {
output.stepShift = 2;
output.step(step);
});

event.dispatcher.on(event.step.started, (step) => {
event.dispatcher.on(event.step.started, step => {
let processingStep = step;
const metaSteps = [];
while (processingStep.metaStep) {
Expand Down Expand Up @@ -118,7 +118,7 @@ class Cli extends Base {
}
}

runner.on('suite end', (suite) => {
runner.on('suite end', suite => {
let skippedCount = 0;
const grep = runner._grep;
for (const test of suite.tests) {
Expand Down Expand Up @@ -159,7 +159,7 @@ class Cli extends Base {
// failures
if (stats.failures) {
// append step traces
this.failures.map((test) => {
this.failures.map(test => {
const err = test.err;

let log = '';
Expand All @@ -172,7 +172,7 @@ class Cli extends Base {

if (steps && steps.length) {
let scenarioTrace = '';
steps.reverse().forEach((step) => {
steps.reverse().forEach(step => {
const line = `- ${step.toCode()} ${step.line()}`;
// if (step.status === 'failed') line = '' + line;
scenarioTrace += `\n${line}`;
Expand Down Expand Up @@ -218,7 +218,7 @@ class Cli extends Base {
console.log();
}

this.failures.forEach((failure) => {
this.failures.forEach(failure => {
if (failure.constructor.name === 'Hook') {
stats.failedHooks += 1;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/codecept.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Codecept {
*/
requireModules(requiringModules) {
if (requiringModules) {
requiringModules.forEach((requiredModule) => {
requiringModules.forEach(requiredModule => {
const isLocalFile = existsSync(requiredModule) || existsSync(`${requiredModule}.js`);
if (isLocalFile) {
requiredModule = resolve(requiredModule);
Expand Down Expand Up @@ -76,7 +76,7 @@ class Codecept {
global.within = require('./within');
global.session = require('./session');
global.DataTable = require('./data/table');
global.locate = (locator) => require('./locator').build(locator);
global.locate = locator => require('./locator').build(locator);
global.inject = container.support;
global.share = container.share;
global.secret = require('./secret').secret;
Expand Down Expand Up @@ -112,7 +112,7 @@ class Codecept {
runHook(require('./listener/exit'));

// custom hooks (previous iteration of plugins)
this.config.hooks.forEach((hook) => runHook(hook));
this.config.hooks.forEach(hook => runHook(hook));
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ class Codecept {

if (this.config.gherkin.features && !this.opts.tests) {
if (Array.isArray(this.config.gherkin.features)) {
this.config.gherkin.features.forEach((feature) => {
this.config.gherkin.features.forEach(feature => {
patterns.push(feature);
});
} else {
Expand All @@ -166,7 +166,7 @@ class Codecept {
}

for (pattern of patterns) {
glob.sync(pattern, options).forEach((file) => {
glob.sync(pattern, options).forEach(file => {
if (file.includes('node_modules')) return;
if (!fsPath.isAbsolute(file)) {
file = fsPath.join(global.codecept_dir, file);
Expand Down Expand Up @@ -194,7 +194,7 @@ class Codecept {
if (!fsPath.isAbsolute(test)) {
test = fsPath.join(global.codecept_dir, test);
}
mocha.files = mocha.files.filter((t) => fsPath.basename(t, '.js') === test || t === test);
mocha.files = mocha.files.filter(t => fsPath.basename(t, '.js') === test || t === test);
}
const done = () => {
event.emit(event.all.result, this);
Expand Down
14 changes: 7 additions & 7 deletions lib/command/gherkin/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function (genPath, options) {
}

const files = [];
glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach((file) => {
glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach(file => {
if (!fsPath.isAbsolute(file)) {
file = fsPath.join(global.codecept_dir, file);
}
Expand All @@ -53,7 +53,7 @@ module.exports = function (genPath, options) {

const newSteps = new Map();

const parseSteps = (steps) => {
const parseSteps = steps => {
const newSteps = [];
let currentKeyword = '';
for (const step of steps) {
Expand Down Expand Up @@ -86,19 +86,19 @@ module.exports = function (genPath, options) {
return newSteps;
};

const parseFile = (file) => {
const parseFile = file => {
const ast = parser.parse(fs.readFileSync(file).toString());
for (const child of ast.feature.children) {
if (child.scenario.keyword === 'Scenario Outline') continue; // skip scenario outline
parseSteps(child.scenario.steps)
.map((step) => {
.map(step => {
return Object.assign(step, { file: file.replace(global.codecept_dir, '').slice(1) });
})
.map((step) => newSteps.set(`${step.type}(${step})`, step));
.map(step => newSteps.set(`${step.type}(${step})`, step));
}
};

files.forEach((file) => parseFile(file));
files.forEach(file => parseFile(file));

let stepFile = options.path || config.gherkin.steps[0];
if (!fs.existsSync(stepFile)) {
Expand All @@ -112,7 +112,7 @@ module.exports = function (genPath, options) {

const snippets = [...newSteps.values()]
.filter((value, index, self) => self.indexOf(value) === index)
.map((step) => {
.map(step => {
return `
${step.type}(${step.regexp ? '/^' : "'"}${step}${step.regexp ? '$/' : "'"}, () => {
// From "${step.file}" ${JSON.stringify(step.location)}
Expand Down
36 changes: 18 additions & 18 deletions lib/command/workers/runTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { options, tests, testRoot, workerIndex } = workerData;

// hide worker output
if (!options.debug && !options.verbose)
process.stdout.write = (string) => {
process.stdout.write = string => {
stdout += string;
return true;
};
Expand Down Expand Up @@ -70,7 +70,7 @@ function filterTests() {
mocha.loadFiles();

for (const suite of mocha.suite.suites) {
suite.tests = suite.tests.filter((test) => tests.indexOf(test.uid) >= 0);
suite.tests = suite.tests.filter(test => tests.indexOf(test.uid) >= 0);
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ function initializeListeners() {
}

if (test.opts) {
Object.keys(test.opts).forEach((k) => {
Object.keys(test.opts).forEach(k => {
if (typeof test.opts[k] === 'object') delete test.opts[k];
if (typeof test.opts[k] === 'function') delete test.opts[k];
});
Expand Down Expand Up @@ -192,7 +192,7 @@ function initializeListeners() {
}

if (step.opts) {
Object.keys(step.opts).forEach((k) => {
Object.keys(step.opts).forEach(k => {
if (typeof step.opts[k] === 'object') delete step.opts[k];
if (typeof step.opts[k] === 'function') delete step.opts[k];
});
Expand All @@ -212,31 +212,31 @@ function initializeListeners() {

collectStats();
// suite
event.dispatcher.on(event.suite.before, (suite) => sendToParentThread({ event: event.suite.before, workerIndex, data: simplifyTest(suite) }));
event.dispatcher.on(event.suite.after, (suite) => sendToParentThread({ event: event.suite.after, workerIndex, data: simplifyTest(suite) }));
event.dispatcher.on(event.suite.before, suite => sendToParentThread({ event: event.suite.before, workerIndex, data: simplifyTest(suite) }));
event.dispatcher.on(event.suite.after, suite => sendToParentThread({ event: event.suite.after, workerIndex, data: simplifyTest(suite) }));

// calculate duration
event.dispatcher.on(event.test.started, (test) => (test.start = new Date()));
event.dispatcher.on(event.test.started, test => (test.start = new Date()));

// tests
event.dispatcher.on(event.test.before, (test) => sendToParentThread({ event: event.test.before, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.after, (test) => sendToParentThread({ event: event.test.after, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.before, test => sendToParentThread({ event: event.test.before, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.after, test => sendToParentThread({ event: event.test.after, workerIndex, data: simplifyTest(test) }));
// we should force-send correct errors to prevent race condition
event.dispatcher.on(event.test.finished, (test, err) => sendToParentThread({ event: event.test.finished, workerIndex, data: simplifyTest(test, err) }));
event.dispatcher.on(event.test.failed, (test, err) => sendToParentThread({ event: event.test.failed, workerIndex, data: simplifyTest(test, err) }));
event.dispatcher.on(event.test.passed, (test, err) => sendToParentThread({ event: event.test.passed, workerIndex, data: simplifyTest(test, err) }));
event.dispatcher.on(event.test.started, (test) => sendToParentThread({ event: event.test.started, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.skipped, (test) => sendToParentThread({ event: event.test.skipped, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.started, test => sendToParentThread({ event: event.test.started, workerIndex, data: simplifyTest(test) }));
event.dispatcher.on(event.test.skipped, test => sendToParentThread({ event: event.test.skipped, workerIndex, data: simplifyTest(test) }));

// steps
event.dispatcher.on(event.step.finished, (step) => sendToParentThread({ event: event.step.finished, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.started, (step) => sendToParentThread({ event: event.step.started, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.passed, (step) => sendToParentThread({ event: event.step.passed, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.failed, (step) => sendToParentThread({ event: event.step.failed, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.finished, step => sendToParentThread({ event: event.step.finished, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.started, step => sendToParentThread({ event: event.step.started, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.passed, step => sendToParentThread({ event: event.step.passed, workerIndex, data: simplifyStep(step) }));
event.dispatcher.on(event.step.failed, step => sendToParentThread({ event: event.step.failed, workerIndex, data: simplifyStep(step) }));

event.dispatcher.on(event.hook.failed, (test, err) => sendToParentThread({ event: event.hook.failed, workerIndex, data: simplifyTest(test, err) }));
event.dispatcher.on(event.hook.passed, (test, err) => sendToParentThread({ event: event.hook.passed, workerIndex, data: simplifyTest(test, err) }));
event.dispatcher.on(event.all.failures, (data) => sendToParentThread({ event: event.all.failures, workerIndex, data }));
event.dispatcher.on(event.all.failures, data => sendToParentThread({ event: event.all.failures, workerIndex, data }));

// all
event.dispatcher.once(event.all.result, () => parentPort.close());
Expand All @@ -260,7 +260,7 @@ function collectStats() {
event.dispatcher.on(event.test.passed, () => {
stats.passes++;
});
event.dispatcher.on(event.test.failed, (test) => {
event.dispatcher.on(event.test.failed, test => {
if (test.ctx._runnable.title.includes('hook: AfterSuite')) {
stats.failedHooks += 1;
}
Expand All @@ -282,7 +282,7 @@ function sendToParentThread(data) {
}

function listenToParentThread() {
parentPort.on('message', (eventData) => {
parentPort.on('message', eventData => {
container.append({ support: eventData.data });
});
}
14 changes: 7 additions & 7 deletions lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function createHelpers(config) {

asyncHelperPromise = asyncHelperPromise
.then(() => HelperClass())
.then((ResolvedHelperClass) => {
.then(ResolvedHelperClass => {
// Check if ResolvedHelperClass is a constructor function
if (typeof ResolvedHelperClass?.constructor !== 'function') {
throw new Error(`Helper class from module '${helperName}' is not a class. Use CJS async module syntax.`);
Expand Down Expand Up @@ -267,7 +267,7 @@ function requireHelperFromModule(helperName, config, HelperClass) {
function createSupportObjects(config) {
const asyncWrapper = function (f) {
return function () {
return f.apply(this, arguments).catch((e) => {
return f.apply(this, arguments).catch(e => {
recorder.saveFirstAsyncError(e);
throw e;
});
Expand Down Expand Up @@ -415,9 +415,9 @@ function createPlugins(config, options = {}) {
}

function loadGherkinSteps(paths) {
global.Before = (fn) => event.dispatcher.on(event.test.started, fn);
global.After = (fn) => event.dispatcher.on(event.test.finished, fn);
global.Fail = (fn) => event.dispatcher.on(event.test.failed, fn);
global.Before = fn => event.dispatcher.on(event.test.started, fn);
global.After = fn => event.dispatcher.on(event.test.finished, fn);
global.Fail = fn => event.dispatcher.on(event.test.failed, fn);

// If gherkin.steps is string, then this will iterate through that folder and send all step def js files to loadSupportObject
// If gherkin.steps is Array, it will go the old way
Expand All @@ -429,7 +429,7 @@ function loadGherkinSteps(paths) {
} else {
const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : '';
if (folderPath !== '') {
glob.sync(folderPath).forEach((file) => {
glob.sync(folderPath).forEach(file => {
loadSupportObject(file, `Step Definition from ${file}`);
});
}
Expand Down Expand Up @@ -498,7 +498,7 @@ function loadTranslation(locale, vocabularies) {
translation = Translation.createDefault();
}

vocabularies.forEach((v) => translation.loadVocabulary(v));
vocabularies.forEach(v => translation.loadVocabulary(v));

return translation;
}
Expand Down
Loading
Loading