christianalfoni / grunt-tdd

Run browser and Node JS tests on Buster, Mocha or Jasmine and get the reports in the browser
3 stars 0 forks source link

Issue with using relative path where source is outside of working directory #3

Open cameroncan opened 9 years ago

cameroncan commented 9 years ago

I am getting the error: Fatal error: Cannot call method 'createPage' of undefined

I can't tell if it is related to #2 or not. I have a maven project and I am running grunt outside of where my source files are. This is the only significant difference I can tell from your examples here and on the main page.

gruntFile.js

...
    console.warn("sources: " + frontendSrcDir);
    console.warn("libs: " + jsTestDependencies);
    console.warn("tests: " + frontendTestFiles);
...

Config:

...
src: {
    files: {
        sources: [frontendSrcDir],
        libs: [jsTestDependencies],
        tests: [frontendTestFiles]
    },
    options: {
        runner: 'jasmine'
    }
}
...

Output:

C:\dev\code\modules\translation\target-grunt>grunt tdd:src --runAll
sources: ../src/main/resources/frontend/**/*.js
libs:
tests: ../src/test/javascript/unit/**/*.js
Running "tdd:src" (tdd) task

Fatal error: Cannot call method 'createPage' of undefined

I do need files specified in the libs property, but I was concerned that wildcards were causing the issue. This is my full use case:

Output:

C:\dev\code\modules\translation\target-grunt>grunt tdd:src --runAll
sources: ../src/main/resources/frontend/**/*.js
libs: imported-js/test/**/jquery-*-min.js,imported-js/test/**/angular-*-min.js,imported-js/test/**/angular-mocks-*.js,imported-js/test/**/jasmine-jquery-*.js,node_modules/**/jsTestingBase.js,node_modules/**/testing-service.js
tests: ../src/test/javascript/unit/**/*.js
Running "tdd:src" (tdd) task

Fatal error: Cannot call method 'createPage' of undefined

When running the tdd task (grunt tdd) with the verbose flag on I see this, which makes me think the error is with the '..' in the path. The first case (where the path is watched) is correct, however, when the page tries to load the files, the '..' are missing and unaccounted for.

Running "watch:__tdd" (watch) task
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.__tdd.files exists in config...OK
Watching ..\src\main\resources\frontend\translation\translation.js for changes.
Watching ..\src\test\javascript\unit\translationTests.js for changes.
Reading C:\dev\code\modules\translation\target-grunt\node_modules\grunt-tdd\src/../staticFiles/template.html...OK
Reading C:\dev\code\modules\translation\target-grunt/imported-js/test/js/com/jquery/jquery/1.8.2/jquery-1.8.2-min.js...OK
Reading C:\dev\code\modules\translation\target-grunt/imported-js/test/js/org/angularjs/angular/1.2.28/angular-1.2.28-min.js...OK
Reading C:\dev\code\modules\translation\target-grunt/imported-js/test/js/org/angularjs/angular-mocks/1.2.28/angular-mocks-1.2.28.js...OK
Reading C:\dev\code\modules\translation\target-grunt/imported-js/test/js/com/github/velesin/jasmine-jquery/2.0.5/jasmine-jquery-2.0.5.js...OK
Reading C:\dev\code\modules\translation\target-grunt/node_modules/360Value.js-testing-base/src/main/js/jsTestingBase.js...OK
Reading C:\dev\code\modules\translation\target-grunt/src/main/resources/frontend/translation/translation.js...ERROR
Fatal error: Unable to read "C:\dev\code\modules\translation\target-grunt/src/main/resources/frontend/translation/translation.js" file (Error code: ENOENT).
Reading C:\dev\code\modules\translation\target-grunt/src/test/javascript/unit/translationTests.js...ERROR
Fatal error: Unable to read "C:\dev\code\modules\translation\target-grunt/src/test/javascript/unit/translationTests.js" file (Error code: ENOENT).

Any ideas on what could be causing this? I haven't been able to get it up and running yet.

cameroncan commented 9 years ago

Another note that may or may not help. I do see this in the npm install:

[INFO] C:\dev\code\modules\translation\target-grunt\node_modules\grunt-tdd\node_modules\buster-test\node_modules\jsdom\node_modules\contextify>if not defined npm_config_node_gyp (node "C:\dev\code\modules\translation\target-grunt\node\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
[INFO] gyp ERR! configure error
[INFO] gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
[INFO] gyp ERR! stack     at failNoPython (C:\dev\code\modules\translation\target-grunt\node\npm\node_modules\node-gyp\lib\configure.js:103:14)
[INFO] gyp ERR! stack     at C:\dev\code\modules\translation\target-grunt\node\npm\node_modules\node-gyp\lib\configure.js:64:11
[INFO] gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15)
[INFO] gyp ERR! System Windows_NT 6.1.7601
[INFO] gyp ERR! command "node" "C:\\dev\\code\\modules\\translation\\target-grunt\\node\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
[INFO] gyp ERR! cwd C:\dev\code\modules\translation\target-grunt\node_modules\grunt-tdd\node_modules\buster-test\node_modules\jsdom\node_modules\contextify
[INFO] gyp ERR! node -v v0.12.0
[INFO] gyp ERR! node-gyp -v v1.0.3
[INFO] gyp ERR! not ok
[INFO] npm WARN optional dep failed, continuing jsdom@0.10.6
[INFO] grunt-npm@0.0.2 node_modules\grunt-npm
christianalfoni commented 9 years ago

Hi @cameroncan,

So sorry for late reply, I have been fighting off a flue that last couple of weeks!

Could you try installing python on your machine? I am not sure about the dependencies beyond the NPM modules, but it I have python on my MAC.