sindresorhus/gulp-jasmine

Jasmine CLI contains --debug and --filter features. Is this supported for running from gulp?

Opened this issue · 4 comments

title.

I'm not familiar with these options, but to filter with gulp you'd use a blob in the gulp.src and to debug you'd start a debugger on your gulp process, so I don't think they are relevant.

Closing this issue. If you think these options should be added, please explain the use case here.

@jbblanchet

My use case for supporting the filter option:

I have application functionality in spec files and group them into suites with describe. Each spec (it) is for a specific use case or test - some of which are quick to execute and some are longer running tests (e.g. selenium-webdriver integration tests in the browser).

When running a CI build following check in, I want quick running tests to reduce execution time and get quick feedback.

Example:

describe('Some Functionality', function() {

    it('should run quickly with a filter [quick]', function(done) { //note [quick] in spec name
        //I'm a fast running positive or happy path test
    });

    it('should be ignored by my CI filter', function(done) {
        //I take a long time to execute and would probably run in a scheduled nightly build
    });

    it('should also ignored by my CI filter', function(done) {
        //I also take a long time to execute and would probably run in a scheduled nightly build
    });
});

When using the CLI, if I run the following command with the filter option, only 1 spec would run:

jasmine --filter="[quick]"

I'd like to see it integrated something like this:

return gulp.src('test/spec/**/*Spec.js')
        .pipe($.jasmine({
            config: require('./test/spec/support/jasmine.json'),
            filter: "[quick]",
            reporter: new $.jasmineReporters.JUnitXmlReporter({
                consolidateAll: true
            })
        }))

What do you think?

Cheers,
Dan

@danhumphrey Sorry for the delay, I was away on vacation.

Filtering by tag seems like a valid use case. I'll reopen the issue.

I don't know if it helps, but this is a programmatic way of executing jasmine tests in nodejs:

const path = require('path')
const Jasmine = require('jasmine')

let specFiles = process.argv[2]
  .split(',')
  .map(f => path.join(__dirname, f))

const jasmineRunner = new Jasmine()
jasmineRunner.specFiles = [."/spec/file1.js", ...]
jasmineRunner.execute()
`