forcedotcom / LightningTestingService

Apache License 2.0
122 stars 35 forks source link

ERROR: Cannot read property 'endsWith' of undefined. #38

Closed madmax983 closed 6 years ago

madmax983 commented 6 years ago

I am getting ERROR: Cannot read property 'endsWith' of undefined. when running sfdx force:lightning:test:run -a jasmineTests.app after upgrading to the GA release of sfdx.

Any ideas on what is going sideways?

esalman-sfdc commented 6 years ago

Hey @madmax983 could you please share details around what you did to move to GA release.

I am using "salesforcedx 41.4.1" (checked using sfdx plugins) and the command runs without any error for me.

madmax983 commented 6 years ago

Hi @esalman-sfdc. I ran the gist here: https://gist.github.com/dcarroll/7d7a4b97a0d77f26c9f6fc6d73b689a6

And then redownloaded and installed the CLI from here: https://developer.salesforce.com/tools/sfdxcli

If I run just sfdx plugins I get "no plugins installed'.

sfdx plugins --core gets me "salesforcedx 41.4.1".

I am going to try to blow away the LTS components and reinstalling with sfdx force:lightning:test:install

madmax983 commented 6 years ago

Update: Uninstalling and reinstalling didn't fix the issue with the original app.

However, I did clone this repo and setup a scratch org against it and the command ran fine. So I think it is fair to say its an environment issue with my original app's workspace. I'll close this out, because it is likely something leftover from the pilot or beta that throwing a wrench in the mix.

esalman-sfdc commented 6 years ago

Hey @madmax983 were you able to figure out the underlying cause. Asking because somebody else has reported a similar issue but there isn’t a repro.

madmax983 commented 6 years ago

@esalman-sfdc I don't know that I figured out the underlying cause, but I did manage to resolve it.

https://github.com/madmax983/lightning-redux is the repo that was experiencing the issue, and you can see the chain of commits on Oct 19th. Matching the travis.yml in this repo is what looked to fix the issue.

I still get the error locally if I try to run it against a non-scratch org, but it works fine locally with scratch orgs. Not sure if that is a limitation on the plugin.

esalman-sfdc commented 6 years ago

Thanks @madmax983. I'll update this thread if we we are able to find the root cause.

By the way on a side note, I don't think you need 'heroku plugins:install salesforce-lightning-cli' anymore as sfdx cli comes packaged with the lint command now :)

esalman-sfdc commented 6 years ago

We determined that that 'endsWith' of undefined error was actually being thrown by the error handling/logging logic in sfdx plugin and essetially ends up masking the actual error. We have logged a bug for that on the plugin team. In the case of force:lightning:test:run most likely the underlying error is related to failure while opening a browser due to environmental issues.

congadevleads commented 6 years ago

I'm struggling troubleshooting this error message in docker image atlassian/default-image, I've installed chromium-browser and tried to set all the ENV vars etc I could from the travis CI example files. Has anyone got this working in a docker image or only with Travis CI?

esalman-sfdc commented 6 years ago

I personally haven't tried using sfdx in a docker image/container. May be searching (on google) for how to run webdriver tests in docker container can provide possible suggestions.

Another user had asked about this here but I am not sure if he was able to find a solution or not.

Underneath the cover, the command uses webdriver.io, and desired capabilities (e.g. browser to use etc.) can be controlled. See my comment here

congadevleads commented 6 years ago

I was able to resolve my issue by running these cli commands before running my tests,

export DISPLAY=:0
Xvfb :0 -ac -screen 0 1024x768x24 &

Then when running tests adding a -f config file which looks like this,

{
  "webdriverio": {
    "desiredCapabilities": {
      "browserName": "chrome",
      "chromeOptions": {
        "args": ["--no-sandbox"]
      }
    }
  }
}

This was while running in atlassian/default-image docker image after installing chrome browser.

esalman-sfdc commented 6 years ago

Glad to hear. Thanks for posting your solution as it may help others.

red-parrot commented 6 years ago

I am not able to run Lightning Test Service on Jenkins(on AWS server). Getting error "Cannot read property 'endsWith' of undefined". I have not tried using docker image/container. Is there any work around to overcome this issue?

esalman-sfdc commented 6 years ago

Kindly go over the details in this thread. Solution should be similar.

frederikladewig commented 6 years ago

Just an additional information to help to identify the correct error: I changed ~/.local/share/sfdx/client/node_modules/salesforce-alm/dist/index.js:185 to: message: err.message || err.name || err,

This helps to get the correct error message logged (which in my case was the following: "ERROR: Lightning Testing Service can only run in scratch orgs, because tests can permanently change org data.")

congadevleads commented 6 years ago

I also made @frederikladewig error handling bug fix to troubleshoot chrome/webdriver issues, salesforce-alm project should fix this. I think chrome-stable introduced a new bug recently that broke my UI tests, to fix I had to commit the chrome user-data Default/Cache folder, for some reason the first time Chrome is launched webdriver has issues communicating with it if the Cache folder does no exist yet.

Had something to do with LogLevels and manifested similar to this Chrome bug, https://bugs.chromium.org/p/chromedriver/issues/detail?id=1773

donaldrivard commented 6 years ago

I am getting the error unknown error: missing or invalid 'entry.level' even after all the changes including upgrading chromedriver. I only get the error when I run the tests using

sfdx force:lightning:test:run -a JasmineTesting.app

BUT if I add -o to that command or run

sfdx force:org:open -p /c/JasmineTesting.app

The tests work fine.

Any ideas?

ChromeDriver 2.34.522932

congadevleads commented 6 years ago

Thanks @donaldrivard, I'm having the same problem. It appears something updated (I think it was chrome) and broke some functionality. "entry.level" appears to have something to do with Chrome logs, see my chromium bug link above. I hand't noticed that -o was a workaround and is better than the solution I was trying. I noticed it has something to do with Chrome user data, specifically Default/Cache folder. Running the command the first time without -o always failed until Chrome created it's user data folder, then consecutive runs would succeed without issue. However this is a problem in my CI as I have a clean Docker image on each run. Thanks for the tip!

donaldrivard commented 6 years ago

@congadevleads I tried the link above but no luck on my machine. I am also using Travis CI in my process and the sfdx force:lightning:test:run -a JasmineTesting.app command works fine in that environment. So it is definitely my machine but I cannot figure out what it is. The frustrating thing is that everything was fine until yesterday.

congadevleads commented 6 years ago

@donaldrivard my issue is different than linked chromium issue as well, I think chrome reintroduced a similar issue by mistake in a recent release and thats why we both suddenly ran in to this issue this week. Hopefully someone is going to fix it...

alexed1 commented 6 years ago

I get this error when I try to run sfdx force:lightning:test:run -a jasmineTests.app from my docker environment. I can run the tests in that app fine if I do it manually from the browser. I already fail on attempts to login to orgs from sfdx from inside my docker container, so this is probably that same problem.

Using the trick frederikladewig suggests, above, the error message that I get becomes "ERROR: An unknown server-side error occurred while processing the command. (UnknownError:13)." So it's the same problem as ws repored here.

positonic commented 5 years ago

setting 'publicPath' fixed this for me