Comments (19)
This allows more flexibility for people to pick the watcher library that works best for them
Why there is the following statement on the Jasmine Docs:
Comes out of the box with everything you need to test your code.
Re-running tests is also a purpose of most of the existing tasks runners.
Take a look at http://mochajs.org as example.
from jasmine-npm.
At this point, I think it makes more sense to leave the code to do the watching of your specs and production code to one of the many external libraries that are built specifically for that. This allows more flexibility for people to pick the watcher library that works best for them, and to update or change it without having to wait for Jasmine to release a new version. It also won't (as @Izhaki says) cause the Jasmine team to have to deal with or troubleshoot any issues related to the watching not working correctly.
Thanks for all the input. Closing this. Thanks for using Jasmine!
from jasmine-npm.
@danmartinez101 if you install nodemon
and jasmine
globally
npm install -g nodemon
npm install -g jasmine
you can just run nodemon --exec jasmine
in command line.
from jasmine-npm.
It can be tricky to be implemented if someone is using babel-node to run their jasmine node tests. I have to use the following code in order to run jasmine test files using babel-node automatically on any changes to test or code:
./node_modules/nodemon/bin/nodemon.js -w spec/lib -w lib ./node_modules/babel-cli/bin/babel-node.js ./node_modules/jasmine/bin/jasmine.js --random=true
The good thing is, it can be put as an npm script as follows:
// package.json
"scripts": {
"watch": "./node_modules/nodemon/bin/nodemon.js -w spec/lib -w lib ./node_modules/babel-cli/bin/babel-node.js ./node_modules/jasmine/bin/jasmine.js --random=true"
}
from jasmine-npm.
I'm going against the stream and would argue jasmine shouldn't support a watch function.
To begin with, I think only very light projects will need a watch on jasmine only. Many projects involve more than one watch.
Then, adding watch to jasmine means adding complexity and maintenance overhead (even if the implementation simply delegates the job to another module).
The task of watching files is not a trivial one - this repository will start seeing issues related to watch not working on Windows, double triggering, no triggering and so forth that have nothing to do with jasmine.
Finally, and most importantly, recall the separation of concerns principle. Ideally jasmine should change for its prime purpose only - running tests.
Don't quite see the issue with this using nodemon
or gulp or grunt or:
"scripts": {
"watch:specs": "chokidar -p 'src/**/*.spec.ts' -c 'npm run test'",
"test": "./jasmine.js"
}
from jasmine-npm.
This works for me:
{
"test": "jasmine",
"test:watch": "nodemon -e js --exec 'npm run test'"
}
from jasmine-npm.
I have found that using nodemon is great for this. Alternatives include supervisor and forever, but nodemon has been the best for me.
It might be worthwhile to look into one of these tools that already handle restarting processes on various events, including filesystem changes.
In my experience, installing jasmine as a local dev dependency and then configuring the npm test command as to run jasmine with nodemon works well.
npm install --save-dev jasmine nodemon
./node_modules/.bin/nodemon ./node_modules/.bin/jasmine
from jasmine-npm.
Can you describe what feature you're interested in a bit more? Is it rerunning your tests every time a file has changed?
from jasmine-npm.
Yep! Anytime a test or a src file has changed, should be configurable probably.
from jasmine-npm.
I was originally doubting the usefulness of this feature, but I played around with something similar and it's not a bad idea. I'd be happy to take a look at a pull request for this.
from jasmine-npm.
yeah I found it super useful in Mocha and jasmine-node.
from jasmine-npm.
This is such a common feature in a test runner, shouldn't have to combine with external tools to mimic it.
It's also incredibly easy to implement using the gaze node lib:
gaze('**/*', function(err, watcher) {
this.on('all', function(event, filepath) {
// rerun jasmine
});
});
I can work up a PR with this if you're interested.
from jasmine-npm.
@geddski I'd still be happy to see a PR on this!
from jasmine-npm.
@amavisca you got it
from jasmine-npm.
Because jasmine-npm uses require
to load your spec file, which probably also use require
to load the system under test, I think it makes the most sense for a jasmine --watch
command to fork
a child process that will get its own require
cache so it will always run with the current code.
from jasmine-npm.
@Isaddo Yea, that is more concise for the most common scenario. I probably should have use that up above... Personally, I like to refrain from installing global cli packages because I often need to use different versions of jasmine, etc for different project concurrently. It may have changed since the last time I tried, but I found that a global install would override a local install so I had to go with the longer commands.
from jasmine-npm.
nodemon --exec jasmine
is working for me. However, would still be nice to have this as part of jasmine.
from jasmine-npm.
Given how easy it is to accomplish this without any changes to jasmine-npm itself, we would prefer to spend our limited development time working on other features. We'd be happy to review a pull request that implements it.
from jasmine-npm.
I'd like to see this too. Some of the other Jasmine test runners implement this (but are missing other features) and seem to get better performance when re-running tests. (presumably some kind of caching going on)
from jasmine-npm.
Related Issues (20)
- jasmine flags, oneFailurePerSpec and stopSpecOnExpectationFailure don't work well HOT 2
- RFC: Well-defined public API HOT 1
- Can't get Jasmine 4 to support .jsx files HOT 7
- Failed to load reporter module jasmine 4.x HOT 1
- Jasmine loads test dependency as CommonJS module instead of ESM HOT 2
- Export Loader HOT 2
- getting an error jasmine.getEnv is not a function HOT 2
- Unable to find specs when using [email protected] HOT 2
- Consider using child_process.fork() to parallelize Jasmine runs HOT 28
- Jasmine 4 ES Modules / Dynamic Import Doesn't Work with Paths that Have Encoded Slashes HOT 4
- jasmine --helper flag broken following addHelperFiles() removal
- --reporter does not work with namespaced modules HOT 4
- Feature Request: Allow re-running test suites without restarting HOT 2
- Package subpath './lib/command.js' is not defined by "exports" using jasmine-xml-reporter HOT 1
- Vulnerabilities found on latest version of Jasmine(4.6.0) HOT 1
- Problem excluding files HOT 4
- Project base dirs containing special Glob syntax don't work HOT 1
- Regression in jasmine 5: settings bleed over to next `Jasmine` instance HOT 4
- `--require` fails with `runner.addRequires is not a function` in 5.x HOT 1
- Add a `--verbose` flag HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jasmine-npm.