I cannot quite figure out how can I use gulp with jasmine. I installed and configured it, so it runs my tests, but I am not sure how to introduce my javascript files to jasmine without the jasmin runner html.
Have you tried gulp-jasmine?
gulp.task('default', function () {
gulp.src('spec/test.js').pipe(jasmine());
});
The src() method can take a glob like 'spec/**/*.js' and automatically run jasmine on all javascript files in the spec directory.
Related
When setting up Mocha how can I say 'Grab all test files in the /tests/specs/ folder and run those`?
This is much more useful than having to explicitly define each test Mocha should include and run.
mocha.setup({
ui: 'bdd',
grep: 'tests/specs/*.Spec.js' // Look for all js files in specs folder
});
There is no option you can pass to mocha.setup to find files.
On the command line you just pass a glob pattern to Mocha (e.g. mocha 'some/subdir/**/*.spec.js', the quotes are to prevent some shells from mangling the glob). You can put it in mocha.opts if you don't want to have to repeat it all the time. The startup script (mocha) will find the files and feed them to the test runner.
If you bypass Mocha's startup script but instead decide to write your own code to setup and drive Mocha, you are responsible for finding the test files and feeding them to Mocha with the .addFile method. An except from this example:
// Add each .js file to the mocha instance
fs.readdirSync(testDir).filter(function(file){
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function(file){
mocha.addFile(
path.join(testDir, file)
);
});
You could use node-glob to replicate globbing functionality if you want.
In the browser, Mocha has no notion of "files" so it cannot be told what files to use. You need to use a module loader like RequireJS or SystemJS and load the modules that contain the tests or bundle all the test files with bundlers like Webpack or Browserify and load the bundle after you load Mocha. Mocha will learn of the available tests when your test files call the functions that Mocha leaks into the global space.
I used ui-router, when the file is not minifed or when I used the already minified file everything is working.
But I have a gulp task that takes all the library and minify them using "uglify()" (this is necessary because some of the library doesn't have a minified version.
So my question is: Do you know why uglify() doesn't work with UI-router
The error I get is:
d.get is not a function
at < a ui-sref="flight" class="ng-scope">
I had the same issue one time, use the mangle option:
.pipe(uglify({ mangle: false }))
It's not ideal because the files won't be as minified as possible but it's working for me
I want to use Laravel Elixir to minify my css/files files. But I don't want to use the mix-methode and merge them. All I want is to generate a "custom.min.js" file from my original "custom.js". Is there a way to do this with Elexir?
EDIT:
To make it a bit clearer: My biggest issue is that I have two folders in "resources/assets": js and css. So I basically want to minify all files in there and have them minified in "public/js" and "public/css".
Quote from the Laravel documentation:
Note: All tasks will assume a development environment, and will exclude minification. For production, use gulp --production.
This means if you want the files to be minified run gulp --production instead of just gulp. It's a better practise than enabling compression directly in the gulp file and makes sure you can debug your compiled files while developing the application.
If you want them to be placed in public/assets/css use the path as a second parameter:
mix.less('app.less', 'public/assets/css');
gulp --production.
Jeffrey way replied on the issue here: https://laracasts.com/discuss/channels/elixir/elixir-doesnt-minify
Or you can find it on the documentation. Enjoy coding!
If you just want to copy .css files, without using LESS or SASS, and don't want to combine files (i.e. you want something like a copy() method with minification ability) you can use method for combining, styles(), by calling it for every .css file and passing filename string without array, for example:
mix.styles('some.css');
mix.styles('node_modules/bootstrap/dist/css/bootstrap.css', null, './');
Same can be done for .js files using scripts() method:
mix.scripts('some.js');
mix.scripts('node_modules/bootstrap/dist/js/bootstrap.js', null, './');
And then you can use gulp (doesn't minify, creates .map files) or gulp --production (creates minified files) as mentioned in above posts.
Straight from the Laravel/Elixir docs:
Elixir is built on top of Gulp, so to run your Elixir tasks you only need to run the gulp command in your terminal. Adding the --production flag to the command will instruct Elixir to minify your CSS and JavaScript files:
Run all tasks... gulp
Run all tasks and minify all CSS and JavaScript... gulp --production
docs: https://laravel.com/docs/5.3/elixir#running-elixir
I want to debug just a single test in webstorm. The mocha options specify a test directory, but I can't seem to point it to just a single test.js file.
How can I debug/run configure a single mocha test using the webstorm debug configuration options?
As a hack, you could configure the mocha command directly with the CLI option:
mocha --grep login-failure.js
Also, you can use the only function to skip all other tests:
describe(function () {
// these tests will be skipped
});
describe.only(function () {
// these tests will run
});
Source: http://jaketrent.com/post/run-single-mocha-test/
As far as I'm aware it's not currently supported.
https://youtrack.jetbrains.com/issue/WEB-10067 -- watch this ticket (star/vote/comment) to get notified on progress.
I solved this by pointing to a random non-test directory as the test directory and passing my single test filename in as an "extra mocha option"
Why not just create a test folder and create your .js test file inside?
I am looking into upgrading brunch to latest version of 1.7.1, but am running into trouble with my mocha tests not being run. Tracked this down to that "window.require('x_test')" at the end of test.js not being generated anymore. Tried renaming my test files from 'x_test.coffee' to 'x-test.coffee' (replacing underscore with dash), to no avail, as the docs indicate that suffix -test will be treated as test according to brunch conventions.
Any ideas?
Additional info: The support disappears between versions 1.5.4 and 1.6.7.
An answer to this question can be found on GitHub: https://github.com/brunch/brunch/issues/726
In short, where you find mocha.run() (in my case, index.html):
<script>
$(function() {
window.require.list().filter(function (name) {return /test$/.test(name);}).forEach(require);
mocha.run();
});
</script>
This executes all javascript/coffeescript files ending with test, hence register the tests they contain, which mocha.run() will subsequently run.