Brunch mocha support gone? - mocha.js

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.

Related

Step definition folder structure in cypress cucumber preprocessor

Versions
Cypress version: 8.4.0
Preprocessor version: 4.2.0
Node version: 12.18.2
Hi all, apologies if this is a stupid question, I'm quite new/noob with cypress, let alone cypress + cucumber.
So I wrote some automation tests in cucumber, and they work fine. I have the feature files in the integration folder, and the step definition folders in the integration folder too. Now I'm trying to have some structure where under integration I have a folder named step_definitions (will show better in screenshot).
folder structure
In package.json I put the following:
"cypress-cucumber-preprocessor": { "nonGlobalStepDefinitions": true, "nonGlobalStepBaseDir": "step_definitions", "commonPath": "common", "stepDefinitions": "step_definitions" }
When I try to run the tests, I get the below error:
Error: We've tried to resolve your step definitions at step_definitions, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.
Any pointers are appreciated :)
It seems to me that the problem in your case in "stepDefinitions": "step_definitions" have you tried to give the full path like "stepDefinitions": "cypress/integration/step_definitions"?
You should set nonGlobalStepDefinitions to false or remove this setting, as you don't have a separate folder for the step_definitions but it is inside the integration folder instead.
So, in order to use your structure, please modify that section in the package.json file to:
"cypress-cucumber-preprocessor": {
"commonPath": "cypress/integration/step_definitions/common",
"stepDefinitions": "cypress/integration/step_definitions"
}
That would be enough. It works.

Grails 3 - Angular template asset pipeline not bundling converted js files into application.js

I'm using Grails 3.1.10, angular-template-asset-pipeline 2.2.6, and asset-pipeline-gradle 2.8.2
It's tough for me to share config files as I work behind a firewall but the general issue is mostly similar to this https://github.com/bertramdev/grails-asset-pipeline/issues/336 (discussion started so i'll have to update question as things go)
Everything works fine under 'grails run-app' but when i run 'grails war':
the templates get correctly converted to js files
are exploded in tomcat under /webapps/myApp/assets
are not present in the application.js bundled result, therefore my app cannot find any html.
Any help appreciated.
I was required to put assets stuff in my application.groovy development environment for run-app to work, but i'm not sure if application.groovy is used when running 'grails war' .. i'm not a fan of having duplicate asset pipeline configurations. (build.gradle as well as application.groovy for each environment)
Thanks!
After i figured out which config file the configuraitons where coming from (run-app -> application.groovy, grails war -> build.gradle) ... i figured it out.
I got it to work with the following steps...
I moved all my templateUrl: 'file.html' calls to templateUrl: '/myApp/file.html' (directives and view code)
i set my "includePathInName= true"
i put my .tpl.html files in grails-app/assets/javascripts/myApp/templates
Important takeaway here is that grails-app/assets/javascripts/templates would not work for me.

Minified files and ui-router

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

in webstorm how to create a mocha test configuration for a single test

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?

Jasmine gulp plugin

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.

Resources