command line - Selective test execution in Karma Jasmine using pattern matching -
i'm having trouble invoking command line option on karma-jasmine allows execution of tests match given pattern. spec reads follows:
/path/to/single-test/main.spec.js
describe('my first test suite', function() { it('always passes', function() { expect(true).tobe(true); }); it('still passes', function() { expect(true).tobe(true); }); }); i'm assuming description (for example "still passes") item against pattern specified grep command line option matched. when attempt run second example based on fact description example containing word "still", both examples executed instead of one:
$ karma start -- --grep=still info [karma]: karma v0.12.35 server started @ http://localhost:9876/ info [launcher]: starting browser phantomjs info [phantomjs 1.9.8 (linux 0.0.0)]: connected on socket 7dn7ez1reap7ch0uzsb0 id 44623726 phantomjs 1.9.8 (linux 0.0.0): executed 2 of 2 success (0.002 secs / 0.001 secs) how execute 1 example based on pattern? official documentation doesn't give sample of usage of pattern matching option.
i read in discussion of pull request, grep option can used in conjunction "fit" , "fdescribe." works when tested. however, in case of using grep "fit", what's purpose of pattern argument grep option? (it nice able execute tests selectively without need augment source code!)
here remainder of files in project reference:
/path/to/single-test/karma.conf.js
module.exports = function(config) { config.set({ basepath: '', frameworks: ['jasmine'], files: ['*.spec.js'], exclude: [], preprocessors: {}, reporters: ['progress'], port: 9876, colors: true, loglevel: config.log_info, autowatch: false, browsers: ['phantomjs'], singlerun: true }); }; /path/to/single-test/package.json
{ "name": "single-test", "version": "1.0.0", "description": "", "scripts": { "test": "echo \"error: no test specified\" && exit 1" }, "author": "", "license": "mit", "devdependencies": { "jasmine-core": "^2.3.4", "karma": "^0.12.35", "karma-jasmine": "^0.3.5", "karma-phantomjs-launcher": "^0.2.0", "phantomjs": "^1.9.17" } }
you have start karma server, specify --grep option in karma runner. i.e. along lines of:
karma start path/to/karma.conf.js then in terminal:
karma run path/to/karma.conf.js -- --grep=still it important set singlerun: false in configuration options.
Comments
Post a Comment