mmanela / chutzpah

Chutzpah is an open source JavaScript test runner which enables you to run unit tests using QUnit, Jasmine, Mocha and TypeScript.
http://mmanela.github.io/chutzpah/
Apache License 2.0
550 stars 142 forks source link

Chutzpah not detecting Chrome #764

Closed ferrx closed 5 years ago

ferrx commented 5 years ago

I'm setting the chutzpah.json options for Engine and EngineOptions.ChromeBrowserPath to use chrome headless, but the trace logs indicate it's still trying to use PhantomJS. It gives me a "timeout occurred" error after about 10s. If I remove the engine properties (leaving it to default to PhantomJS), everything runs smoothly.

I don't see any reference to Chrome in the logs. I see my chutzpah.json references, but it doesn't seem to catch my engine properties.

Using chutzpah 4.4.5 and Chrome 74.0.3729.169.

{
  "Engine": "Chrome",
   "EngineOptions": {
        "ChromeBrowserPath": "C:\\yadayadayada\\chrome.exe"
   },
  "Framework": "jasmine",
  "TestHarnessLocationMode": "SettingsFileAdjacent",
  "Tests": [
    { "Includes": [ "*.html" ] }
  ]
}
ferrx commented 5 years ago

Still getting this error -- however I was trying to get away from PhantomJS because of errors it was throwing. It turned out those errors were because I was pulling in Jasmine 2.99 -- I switched in the jasmine bits that came with the chutzpah nuget and no more errors, so sticking with that for now.

mmanela commented 5 years ago

I am unable to repo this issue. I was able to specify the chrome path and it works with this json


{
  "Engine": "Chrome",
  "Framework": "Jasmine",   
   "EngineOptions": {
        "ChromeBrowserPath": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
   },
  "TestHarnessLocationMode": "SettingsFileAdjacent",
  "Tests": [
    { "Includes": [ "*test.js" ] }
  ]
}

image

You can also try leaving off the engineOptions and see if it will find the chrome instance via its built in detection

ferrx commented 5 years ago

Thanks. Here's a hint -- I noticed you have a js file in your Tests.Includes, but I'm using *.html in mine.

If I switch to .js it works, but using .html does not work. Maybe there's some extra setup in the html harness to get chrome-headless working?

mmanela commented 5 years ago

I don't support directly running your own HTML test file under Chrome or JsDom.

ferrx commented 5 years ago

Any plans for that? I have a project that is jQuery heavy and needs that. I'll stick with Phantom for now.

mmanela commented 5 years ago

No plans, there are technical reasons why I don't support it. However, you can usually get chutzpah to work with jquery and let it generate the html file itself

ferrx commented 5 years ago

Can you provide an example w/ chutzpah running tests on JS files that have jQuery dependencies? I'm just a little lost, the idea is to be able to interact and manipulate with the "DOM" (whatever you want to call that within a headless browser) with jQuery.. meaning execute jQuery selectors, etc.

mmanela commented 5 years ago

Take a look at this example

It uses jquery and it also uses HTML files that get injected into the dom and then queried on.

ferrx commented 5 years ago

I duplicated that example, it didn't work for me until I took out this includes from chutzpah.json:

  "Tests": [
    { "Includes": [ "*.js" ] }
  ]

It was complaining that it couldn't find the $ variable, as if it couldn't load the inline referenced jquery.js file.

Edit: Sorry to add on like this, but does Tests.Includes override inline references? I also got it working by removing the inline ref and adding a ref in chutzpah.json to include jquery.js (unlike the example..):

  "Tests": [
    { "Includes": [ "*.js" ] }
  ],
  "References": [
    { "Path": "../wwwroot/lib/jquery/dist/jquery.js" }
  ]
mmanela commented 5 years ago

Perfect!

mmanela commented 5 years ago

Are you unblocked now?

ferrx commented 5 years ago

Unblocked when using PhantomJS and html files as an entry point, yes. Definitely the "not detecting Chrome" issue is clarified and resolved.