How to run a single test file with Karma/Jasmine?

本小妞迷上赌 提交于 2019-12-05 01:03:40
Pieter Willaert

Although it's not ideal, you can replace describe (and it) with fdescribe (and fit) so only those tests will be executed

On the other hand, xdescribe / xit excludes the tests from your suite

If you use Gulp, you can combine gulp-karma & yargs to pass in a pattern as argument.

source: https://stackoverflow.com/a/27696472/1782659

If you are like me and you've inherited a suite of tests that are controlled by a task runner (e.g. gulp) and you are getting failures but are unsure which file is actually failing you can sanity check an individual file by running jasmine directly against it:

1.) Make sure you have jasmine installed (it may not be if wrapped inside your task runner configuration)

npm install jasmine

2.) Run jasmine against file:

./node_modules/.bin/jasmine /path/to/my/spec/file.js

or

./node_modules/jasmine/bin/jasmine.js /path/to/my/spec/file.js
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!