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

Reference Error on Jquery Sign, ReferenceError: Can't find variable: $ #785

Closed PramodMn007 closed 4 years ago

PramodMn007 commented 4 years ago

Getting Reference error on Jquery Sign , even after adding Jquery Reference(Complete URL not Local Jquery path) in JS Test file. \\\ <reference path="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"/>

Happening both in VSTest Azure Devops Task & Chutzpah test Adapter for Visual Studio

mmanela commented 4 years ago

Can you share your chutzpah.json file contents?

PramodMn007 commented 4 years ago

Hi Mmanela,

Here goes my Chutzpah.json file.

{
  "Framework": "jasmine",
  "FrameworkVersion": "2.6.4",
  "RootReferencePathMode": "SettingsFileDirectory",
  "EnableTestFileBatching": true,
  "TestFileTimeout": 10000,
  "References": [
    { "Path": "./Scripts/jasmine/jasmine.js" },
    { "Path": "./script.js" },
    { "Path": "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" }
  ],
  "Tests": [
    {
      "Path": "",
      "Includes": [ "*_Tests.js" ]
    }
  ],
  "CodeCoverageExecutionMode": "Always",
  "CodeCoverageIncludes": [ "./script.js" ],
  "CodeCoverageExcludes": [ "./Scripts/jasmine/*.js", "./Tests/*_Tests.js" ],
  "Transforms": [
    { "Name": "lcov", "Path": "lcov.lcov" }
  ]
}

Also , I have a reference for Jquery in my Test JS File.

mmanela commented 4 years ago

Couple things.

  1. Does it work if you load jquery locally instead of CDN?
  2. Does it work if you change the line to
    
    { "Path": "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" , "IsTestFrameworkFile": true }
PramodMn007 commented 4 years ago

Using IsTestFrameworkFile property resolved the Issue. Thanks a Lot...

Also I'm facing TypeError on String Includes function. Error: Message: TypeError: undefined is not a constructor (evaluating 'str.includes("world")')

Function is pretty simple.

//str is of type string
function stringincludes(str) {
    var n = str.includes("world");
    return n;
}

Works fine on Jasmine standalone Test, Facing the issue when I run it through Test Explorer

mmanela commented 4 years ago

Which engine are you running Chutzpah with? By default still it uses Phantom which has older version of ECMAscript, if you use JsDom or Chrome engines newer Js function will work.

PramodMn007 commented 4 years ago

Hi Mmanela,

I'm using Default Phantom engine.. Can you guide me, on using chrome engine?

Thanks & Regards, Pramod

mmanela commented 4 years ago

See this page https://github.com/mmanela/chutzpah/wiki/Browser-Engines

PramodMn007 commented 4 years ago

Thanks a lot...I will check this out...