jasmine-contrib / grunt-jasmine-node

Grunt task for running jasmine-node
MIT License
67 stars 99 forks source link

TypeError: Cannot read property 'result' of undefined in grunt watch #9

Open maksimr opened 11 years ago

maksimr commented 11 years ago

Hello! I have a problem with grunt watch and grunt-jasmine-node. When I run grunt watch and change some files first run grunt-jasmine-node is ok, but second fails with error 'TypeError'.

Any suggestions?

Thanks!

grunt.js:

    grunt.initConfig({
        jasmine_node: {
            projectRoot: './test'
        },
        ...
        watch: {
            files: '<config:lint.files>',
            tasks: 'jasmine_node'
        }
    });

trace:

Running "watch" task
Waiting...
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
  TypeError: Cannot read property 'result' of undefined
  at Object.jasmineNode.TerminalVerboseReporter.buildMessagesFromResults_ (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/reporter.js:241:25)
  at Object.jasmineNode.TerminalVerboseReporter.buildMessagesFromResults_ (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/reporter.js:253:14)
  at Object.jasmineNode.TerminalVerboseReporter.reportRunnerResults (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/reporter.js:217:12)
  at null.reportRunnerResults (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:1788:39)
  at jasmine.Runner.finishCallback (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2160:21)
  at null.onComplete (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2144:10)
  at jasmine.Queue.next_ (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2106:14)
  at onComplete (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2092:18)
  at jasmine.Suite.finish (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2478:5)
at null.onComplete (/home/{project}/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2522:10)

Tests files locate in './test' directory:

test/
     test_spec.js
s9tpepper commented 11 years ago

I don't really use grunt.watch so I haven't run into this. Do you have a test project or something I can look at? Like a repo or something?

maksimr commented 11 years ago

https://github.com/maksimr/grunt-jasmine-issue

Now it fail with other Error. Test fail but grunt write that 'Done, without errors.'

drouillard commented 11 years ago

@maksimr I ran into a similar issue when trying to run this plugin alongside an express plugin that required the nospawn option to be specified when using watch.

I found another grunt plugin that worked for me

https://github.com/tmtk75/grunt-contrib-jasmine-node

Might work as a temporary workaround for you until this issue is closed.

dnephin commented 10 years ago

It looks like grunt-contrib-jasmine-node is now deprecated (according to that link).

I've run into this problem as well (this task with grunt-contrib-watch and spawn option set to false). The first run is fine (tests pass), the second and following runs it is trying to run the entire test suite multiple times (3 times on the second run, 5+ on the third, etc).

I've been able to set the grunt-contrib-watch spawn option to true for now, but that is noticeably slower, so I would like to disable it again. It sounds like the issue is this task holding onto some global references between runs?

dnephin commented 10 years ago

Note: pr #34 fixes this problem

s9tpepper commented 10 years ago

I merged PR #15 which had multi task support and fixed for CoffeeScript, I am not sure that it also fixed these issues with watch. I will set up a project tomorrow and test if #15 also fixes it like #34 did, if not I'll look through PR #34 and see what else was changed there to fix the issue when using watch.