Skip to content
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

fix: undefined global codeceptjs dir #3514

Closed
wants to merge 3 commits into from

Conversation

kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

  • Description of this PR, which problem it solves
  • Resolves #issueId (if applicable).

Applicable helpers:

  • WebDriver
  • Puppeteer
  • Nightmare
  • REST
  • FileHelper
  • Appium
  • Protractor
  • TestCafe
  • Playwright

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@kobenguyent
Copy link
Collaborator Author

----------------------
? Feature which is being tested (ex: account, login, etc) with custom helper
? Filename of a test with_custom helper_test.ts
[class Playwright extends Helper]
{ CustomerHelper: [class CustomerHelper extends Helper] }

Test for with_custom helper_test.ts was created in C:\Users\nguyenth\Desktop\helloworld\with_custom helper_test.ts
PS C:\Users\nguyenth\Desktop\helloworld> npx codeceptjs gt
Creating a new test...
----------------------
? Feature which is being tested (ex: account, login, etc) no custom helper
? Filename of a test no_custom helper_test.ts
[class Playwright extends Helper]

Test for no_custom helper_test.ts was created in C:\Users\nguyenth\Desktop\helloworld\no_custom helper_test.ts

Custom Helper:

export class CustomerHelper extends Helper {

}

Copy link
Contributor

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't like this fix
also I didn't understand when the bug happens

@@ -8,6 +8,9 @@ const recorder = require('./recorder');
const event = require('./event');
const WorkerStorage = require('./workerStorage');
const store = require('./store');
const { getTestRoot } = require('../lib/command/utils');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against including this into a container
container should not know anything about filesystem

Copy link
Contributor

@mirao mirao Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just solved it to myself by putting of global.codecept_dir = testsPath; after

const testsPath = getTestRoot(genPath);

But still there is an issue that all custom helpers need to have included const Helper = require('@codeceptjs/helper');, otherwise you get the issue #3512 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But still there is an issue that all custom helpers need to have included const Helper = require('@codeceptjs/helper');, otherwise you get the issue #3512 (comment)

On the other hand

  • Newly created Helpers (by codeceptjs gh) have the variable Helper set
  • I can fix my existing custom helpers easily
  • As for other custom helpers that I use, only codeceptjs-chai doesn't have Helper set and I must patch it. Others (codeceptjs-cmdhelper, codeceptjs-dbhelper and codeceptjs-pixelmatchhelper) are already set correctly.

So it's not a big issue.

Copy link

@zhigulin-n zhigulin-n Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirao, how did you patch codeceptjs-chai helper? I have TS config and this solve doesn't work for me... :( I talk about your #3611

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhigulin-n

[email protected]:

diff --git a/index.js b/index.js
index bd248fce8c1581fe07a63abae3a469159e7891ca..7cd6dcca0e8ba1e47195e8053f07187ca08782ca 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+const Helper = require('@codeceptjs/helper');
+
 /* eslint-disable global-require */
 const chai = require( 'chai' );
 

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SitamJana/codeceptjs-chai#39

Perhaps this patch would help in general

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobenguyent Thanks. Your PR really helps to solve the issue and therefore my patch is not needed anymore.
I tested that then codeceptjs run and codeceptjs gt work well in a project using codeceptjs-chai.

@kobenguyent
Copy link
Collaborator Author

Hey @DavertMik i guess the issue is from here #3512 but not enough knowledge where to put fix. So leave it to you then.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants