jasmine-contrib / grunt-jasmine-node Goto Github PK
View Code? Open in Web Editor NEWGrunt task for running jasmine-node
License: MIT License
Grunt task for running jasmine-node
License: MIT License
Given the following structure
project/
Gruntfile.js
spec/
someSpec.js
In spec/someSpec.js , I have :
var assert = require("assert");
describe('something', function(){
it('should do stuff', function(){
assert.equal(0, 42);
});
});
And my Gruntfile has this config for jasmine_node :
jasmine_node : {
test : {
options : {
forceExit: true,
match: '.',
matchall: false,
extensions: 'js',
specNameMatcher: 'spec',
},
all : ["spec/"]
}
}
Tests are never run :
grunt jasmine_node:test
Running "jasmine_node:test" (jasmine_node) task
util.print: Use console.log instead
undefinedutil.print: Use console.log instead
Finished in 0.001 secondsutil.print: Use console.log instead
util.print: Use console.log instead
0 tests, 0 assertions, 0 failures
util.print: Use console.log instead
util.print: Use console.log instead
Done, without errors.
I'm obviously missing something huge, but I can't figure out what...
Is this something that could be added? I could created a pr if needed.
I am trying to add the autotest
option to the definition of my jasmine_node
task and it is not being respected. When I make a change and save the tests I'm currently working on they do not rerun.
My task definition is pretty simple:
jasmine_node: {
projectRoot: './test/jasmine/',
requirejs: false,
forceExit: true,
autotest: true
}
I see that autotest
is located in the source (tasks/jasmine-node-task.js) but it looks like nothing is ever done with that option.
I would be willing to put together a fix for this if you would like, as it would speed up my teams development quite a bit.
Let me know/if there's anything I'm missing or doing wrong here. Thanks!
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
Currently this is not running with grunt 4.x.
It keeps telling me:
´´´
Warning: Task "jasmine_node" not found. Used --force, continuing.
´´´
it seems that the 'all' option is to set the folder that contains tests, but whatever i set, it runs all my tests not only in the folder defined in 'all' but it searched all folders to find everything which has filename with 'spec' and with extension 'js'...
Just wanted to know.
If help is needed, maybe add contributors?
It took me a long time of reading the source code of this plugin and node-jasmine to try and understand what was wrong with my grunt config options. I have a pretty standard suite of tests(all written in CoffeeScript and couldn't get things to work to save my life. I finally got my configuration to work with the following(using load-grunt-config):
'use strict'
module.exports =
projectRoot: 'spec'
forceExit: true
useCoffee: true
extensions: 'coffee'
This config doesn't do exactly what I want but I was happy to get it to finally work at all. It would be very helpful if the documentation for this project were much more verbose so that I didn't have to do so much reading to get a simple config object to look right. I'd be happy to help with this documentation bit I need a bit of help getting started at least.
Which uses a all
option?
Wouldn't it be better to use "jasmine" module instead of "jasmine-node"?
Advantages:
NPM: https://www.npmjs.org/package/jasmine
Repository: https://github.com/jasmine/jasmine-npm
My extremely simple specs folder containg a single test with a single assertion is ran twice. The jasmine_node
object is simply {specFolders: ['specs']}
, though I've used a number of additional but equally unhelpful options in an attempt to fix it.
Any ideas?
I want to use Sourcegraph for grunt-jasmine-node code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/jasmine-contrib/grunt-jasmine-node. (It should only take 30 seconds.)
Thank you!
Hello,
is there a way to use this feature mhevery/jasmine-node#229 from grunt?
Exception while requiring modules are causing the build to return with a 0
exit code.
Since jasmine-node 1.7, error stack trace can be suppressed with a --noStack flag. How can I pass this flag from inside grunt?
Grunt file configuration:
jasmine_node: {
options: {
jUnit: {
report: true,
savePath : './build/reports/jasmine',
useDotNotation: true,
consolidate: true
}
},
all: ['spec/']
},
...
grunt.registerTask('integrationtest', ['jasmine_node']);
Installed
└── [email protected]
[email protected] node_modules/jasmine-node
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
Getting this error running the integration tests:
Failed to execute "jasmine.executeSpecsInFolder": TypeError: undefined is not a function
at Object.jasmine.executeSpecsInFolder (/Users/foo/git/ETLaaS/node_modules/grunt-jasmine-node/node_modules/jasmine-node/lib/jasmine-node/index.js:100:28)
at Object.<anonymous> (/Users/foo/git/ETLaaS/node_modules/grunt-jasmine-node/tasks/jasmine-node-task.js:96:17)
at Object.<anonymous> (/Users/foo/git/ETLaaS/node_modules/grunt/lib/grunt/task.js:264:15)
at Object.thisTask.fn (/Users/foo/git/ETLaaS/node_modules/grunt/lib/grunt/task.js:82:16)
at Object.<anonymous> (/Users/foo/git/ETLaaS/node_modules/grunt/lib/util/task.js:301:30)
at Task.runTaskFn (/Users/foo/git/ETLaaS/node_modules/grunt/lib/util/task.js:251:24)
at Task.<anonymous> (/Users/foo/git/ETLaaS/node_modules/grunt/lib/util/task.js:300:12)
at /Users/foo/git/ETLaaS/node_modules/grunt/lib/util/task.js:227:11
at process._tickDomainCallback (node.js:463:13)
at Function.Module.runMain (module.js:499:11)
Setting report
to false
allows the tests to run.
Is there a possible configuration problem my end?
I use RequireJs in jasmine-node and i get the following error when upgrading from 0.1 to 0.2:
[ReferenceError: requirejs is not defined]
Because the parameters in the Grunt config file are not passed, the retrieving of the config parameters is somehow broken (var options = this.options({ ... }))
Hi! I know you asked for this a long time ago, and I've finally implemented it. You can now require jasmine-node (2.0) like require('jasmine-node')
, it gives you the default options object and the run function. Just populate the defaults object as desired and then pass it to run
. Currently this branch is in develop, it's named Jasmine2.0. If you have any time to test it out/update your grunt module to work with it, i'd much appreciate it.
Thanks!
Hi, is there a way to set the requireJsSetup property for jasmine-node?
I was browsing grunt-jasmine-node
on npm on https://npmjs.org/package/grunt-jasmine-node but it turns out the urls in the package.json
are not correct:
They use s9tpepper's git account while the repos is now here.
I tried adding a single line to the existing sample spec at line 13
var spyObj = createSpyObj();
This throws error
Message: ReferenceError: createSpyObj is not defined
spyOn works; just spy creation functions don't work.
I get this error when attempting to call a function in my code with a setTimeout
in it. I'd paste the function, but it's just a dumb function with a setTimeout
and all the test does is call said function. Perhaps this is a problem in jasmine_node that has since been fixed in a newer version?
If I invoke the jasmine_node task with the "teamcity" option set to true, I see Teamcity-friendly console output for the task, but Grunt stops executing abruptly after the jasmine_node task completes. There is no error output, even on verbose mode.
I've distilled the problem down to a simple Grunt project and package.json. I can reproduce the problem on both OS X & CentOS. Here's my Gruntfile:
'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
clean: {
all: ['.tmp']
},
// Tests for server-side node components
jasmine_node: {
specFolders: ["./spec" ],
projectRoot: "./app",
// if 'deploy.project' is given, the build is running in TeamCity
teamcity: !!grunt.option('deploy.project'),
forceExit: true,
jUnit: {
report: false,
savePath : "./reports/",
useDotNotation: true,
consolidate: true
}
}
});
grunt.registerTask('default', [
'clean',
'jasmine_node',
'clean'
]);
};
And my package.json:
{
"name": "grunt_bug",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-jasmine-node": "~0.1.0",
"grunt-contrib-clean": "0.4.0"
},
"engines": {
"node": ">=0.8.0"
}
}
I expect that running 'grunt' executes the tasks clean, jasmine_node and clean again, in that order. This is exactly what happens if I invoke grunt without my 'deploy.project' option to enable teamcity reporting:
$grunt
Running "clean:all" (clean) task
Running "jasmine_node" task
main.calculate(a, b)
adds two numbers: a & b
Finished in 0.005 seconds
1 test, 1 assertion, 0 failures
Running "clean:all" (clean) task
Done, without errors.
$
If I invoke it with 'deploy.project' however, It runs the first 'clean' and jasmine_node, but grunt exits before executing the second 'clean' and completing the build.
$grunt --deploy.project=Foo
Running "clean:all" (clean) task
Running "jasmine_node" task
##teamcity[testSuiteStarted name='main.calculate(a, b)']
##teamcity[testStarted name='adds two numbers: a & b' captureStandardOutput='true']
##teamcity[testFinished name='adds two numbers: a & b']
##teamcity[testSuiteFinished name='main.calculate(a, b)']
$
I would expect it to execute all three tasks. I spent some time looking at the jasmine-reporters code for the Teamcity reporter, but I cannot understand why this is happening.
I think the initConfig is wrong in the Readme. Instead of:
grunt.initConfig({
jasmine_node: {
specNameMatcher: "./spec", // load only specs containing specNameMatcher
projectRoot: ".",
...
}
});
We should have:
grunt.initConfig({
jasmine_node: {
options: {
specNameMatcher: "./spec", // load only specs containing specNameMatcher
projectRoot: ".",
...
}
}
});
I have tried without the options attr and it didn't work.
I'm trying to override the includeStackTrace default which I assume has the same effect as the --noStack argument. For some reason setting it doesn't seem to have any effect. I see jasmine-node is using the option: https://github.com/mhevery/jasmine-node/blob/master/lib/jasmine-node/index.js#L95
I'm new to grunt, am I misunderstanding the proper way to configure the task?
jasmine_node: {
options: {
includeStackTrace: false
},
all: ['spec/']
}
In my spec helper, I have changed the default timeout to 10 seconds using:
jasmine.getEnv().defaultTimeoutInterval = 10 *1000
This works fine when run through the jasmine-node timeout. However, when I use the grunt plugin, it goes back to the standard 5 seconds default.
I am using node 0.10.29, grunt 0.4.5, jasmine-node 1.14.3, grunt-jasmine-node 0.2.1
Given the following task configuration
jasmine_node: {
specNameMatcher: "./specs", // load only specs containing specNameMatcher
projectRoot: ".",
useCoffee:true,
extension:'coffee',
verbose:true,
requirejs: false,
forceExit: true,
jUnit: {
report: false,
savePath : "./build/reports/jasmine/",
useDotNotation: true,
consolidate: true
}
my specs inside /specs/*_/_Spec.coffee are not executed.
The issue introduced by the jasmine reporters upgrade (#46) is compounded by the fact that that the failure of jasmine.executeSpecsInFolder is caught and simply logged, causing the task to exit with 0 when jasmine fails to run.
Specs failing to run due to the runner crashing should cause a build to fail.
Hello -
I am not sure if I am doing it right but when I run "grunt jasmine:test" I get ..
Running "jasmine:test" (jasmine) task
Testing jasmine specs via phantom
0 specs in 0.058s.
0 failures
Here is the snippet of the specs file
jasmine : {
test: {
src : ['public/javascripts/**/*.js'],
options : {
specs : 'spec/client/**/*.js'
, vendor: [
'public/vendor/jquery-2.0.2.min.js'
, 'public/vendor/jasmine-jquery.js'
, 'public/vendor/dust-core-1.2.3.min.js'
, 'node_modules/requirejs/require.js'
, 'vendor/bootstrap/js/bootstrap.min.js'
]
, junit: {
path: "./build/reports/jasmine/"
, consolidate: true
}
, template: require('grunt-template-jasmine-istanbul')
, templateOptions: {
coverage: 'public/coverage/client/coverage.json'
, report: 'public/coverage/client'
}
}
}
},
Here are the contents of spec file ..
$ cat spec/client/loginfb1Spec.js
require(['request'], function(request){
describe('HTTP request', function () {
it('responds with an "Example" page', function (done) {
request('http://localhost:3000', function (err, response, body) {
runs(function () {
expect(err).toBeNull();
expect(response.statusCode).toEqual(200);
expect(body).toContain('login-with-facebook.png');
expect(body).toContain('XX-with-facebook.png');
});
done();
});
});
});
});
Couple of observations:
I see that the _SpecRunner.html gets created during the run time but looks like it gets deleted.
If my intentionally make a mistake on the spec file, it seem to pick that up and error out. Does this means that the spec file is being considered but not processed when it is right?
Shekar
Assume I have these dev dependencies in the package.json
:
{
//...
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.9",
"grunt-contrib-coffee": "~0.7.0",
"grunt-jasmine-node": "~0.1.0"
},
//...
}
And that the Gruntfile.js
looks like this:
module.exports = function(grunt) {
grunt.initConfig({
coffee: {
build: {
files: {
'destination.js': 'source.coffee'
}
}
},
jasmine_node: {
extensions: 'coffee'
}
});
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.registerTask('default', ['jasmine_node', 'coffee']);
};
When running grunt
, the jasmine_node
task is executed, but even if the tests pass, the grunt
command shows a warning (see below) and the coffee
task is never run.
# ...
224 tests, 367 assertions, 0 failures
Warning: Cannot call method 'splitArgs' of undefined Use --force to continue.
Aborted due to warnings.
However, if the jasmine_node
task is added last, the grunt
command does not fail:
# ...
224 tests, 367 assertions, 0 failures
Done, without errors.
Note that my configuration for jasmine node is very small, so I'm not sure if this is an issue with my current configuration, grunt-jasmine-node
or with grunt
itself.
It is also worth noting that any other tasks that I put in the array other than the jasmine_node
task seem to run just fine (no warnings/errors in the output) no matter the order in which they are specified.
Any ideas?
In trying to get jasmine-node working with grunt for e2e tests, I keep getting Fatal error: undefined is not a function.
when trying to write "node-style tests".
Output from the following tests returns Fatal error: asyncSpecDone is not defined
it 'should pass', () ->
expect(1+2).toEqual 3
it 'shows async test', () ->
setTimeout (->
expect('second').toEqual 'second'
asyncSpecDone()
), 1
expect('first').toEqual 'first'
asyncSpecWait()
it 'shows async test node-style', (done) ->
setTimeout (->
expect('second').toEqual 'second'
done()
), 1
expect('first').toEqual 'first'
How do I get grunt-jasmine-node to work with these tests? If it's not possible, how can these tests be updated to work with grunt-jasmine-node?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.