Comments (8)
Closing because not an issue AND not related to gulp-jasmine. Stack overflow would be a much better option for asking such a question.
I can still say that if you look at the source code, there's a well identified section of code that clears the cache. Not sure if that's your problem, but it's as good a place as any to start.
from gulp-jasmine.
Good news is I'm able to reproduce your problem. Bad news is, I'm not familiar with the helpers and their usage. I understand what's happening, but I don't understand the fix yet.
When we load the config, the helper files are identified correctly. When jasmine is executed, it calls the loadHelpers method that requires each helper file. Since the node require mechanism is used, these files are cached. Every other require will simply use the cache, and the file will not be run again.
When the helper is required for the first time, you attach some methods to the jasmine instance. When your tests are run again, we use a new jasmine instance, and since the files have been cached, they are not executed again.
We normally clear the cache for every spec files and its children since they are loaded through gulp. We do not do that with helper files. The most obvious solution would be to clear the files in gulp-jasmine, but that would imply either reading the config file ourselves, or accessing the lists of helpers file and clearing them from the cache just before we run the execute method. My favorite method would be for jasmine to clear the cached files itself, but I'm not sure if they're interested in such a solution.
@sindresorhus @amavisca what do you think?
from gulp-jasmine.
Yes, the cache is cleared, but gulp-jasmine does not reload my helpers. This is certainly an issue with gulp-jasmine, unless I misunderstand the scope of this repo.
from gulp-jasmine.
I'm not sure I understand what you're doing. Are you using gulp-jasmine to run your tests, or are you using jasmine directly through the shell?
from gulp-jasmine.
I have tried both. I would prefer using gulp-jasmine, but when I run it in a watch task, the first time it detects a change, jasmine runs as expected - the second time, it runs but fails on all tests that use any helper libraries I'm loading in (ie jasmine-matchers, and other similar tools). These are installed as node_modules, which I'm under the impression is being cleared in the cache delete, so it means either jasmine doesn't know to re-require the helpers, or gulp-jasmine isn't reloading those.
from gulp-jasmine.
OK, sorry I misunderstood your problem. I'll reopen the issue. Do you have a simplified code sample of a test file so I can try to reproduce your issue?
from gulp-jasmine.
Sure
gulpfile.js
var coffee, gulp, gutil, jasmine, rm, watch;
gulp = require('gulp');
jasmine = require('gulp-jasmine');
watch = require('gulp-watch');
coffee = require('gulp-coffee');
gutil = require('gulp-util');
rm = require('gulp-rm');
gulp.task('test', ['jasmine']);
gulp.task('watch', function() {
return watch(['app/**/*.coffee', 'spec/**/*.coffee'], function() {
return gulp.run(['clean', 'compile', 'test']);
});
});
gulp.task('clean', function() {
return gulp.src(['./spec/full/**/*.js', './spec/factories/*.js', './spec/fixtures/*.js']).pipe(rm());
});
gulp.task('compile', ['clean'], function() {
return gulp.src('./spec/**/*.coffee').pipe(coffee({
bare: true
})).on('error', gutil.log).pipe(gulp.dest('./spec/'));
});
gulp.task('jasmine', ['compile'], function() {
return gulp.src('./spec/**/*.spec.js').pipe(jasmine({
config: require('./spec/support/jasmine.json')
}));
});
spec/support/jasmine.json
{
"spec_dir": "spec",
"spec_files": [
"**/*.spec.js"
],
"helpers": [
"helpers/**/*.js"
]
}
Running gulp test
works perfectly. Running gulp watch
seems to run fine; I can trigger the test task when I save a file as expected, but when I trigger the task by saving a second time, I get a ton of errors saying the methods the helpers install are no longer available.
My tests are all written in coffeescript, and they are compiled into javascript, and the fact that gulp test
works every time tells me this isn't the issue, so I just wanted to clear that off the table.
from gulp-jasmine.
Submitted a pull request, @mrozbarry if you could try it to confirm it fixes your issue it would be appreciated.
from gulp-jasmine.
Related Issues (20)
- Unable to give references of file needed in specs from gulpfile.js
- Issue DEPRECATION : Setting randomizeTests directly is deprecated, please use the random option in `configure`
- Update Jasmine to 3.4 HOT 2
- Upgrade to jasmine 4 HOT 3
- issues with require caching HOT 4
- export jasmine object HOT 9
- Replace silent reporter with onComplete callback
- Error trying to use config in Node 6
- Broken with Jasmine 2.5.0? HOT 9
- Config option for custom Jasmine-instance HOT 4
- gulp-jasmine runs the tests twice when Jasmine version is 2.5.2 HOT 3
- Tests that should fail pass using gulp-jasmine HOT 1
- jasmine doesn't seem to run HOT 1
- Jasmine never getting called if over 16 files loaded HOT 2
- jasmineDone event not called when tests fail
- process exits with exit code 0 when tests fail HOT 3
- Cannot load module using require.
- deleteRequireCache blows the stack for circlular referenced files HOT 3
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. HOT 1
- Running a focused test throws an error when it shouldn't. 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 gulp-jasmine.