Skip to content

Commit

Permalink
fix(filter): match any portion of a spec name (#270)
Browse files Browse the repository at this point in the history
jasmine tests are named suite-name + spec-name. The links printed by
karma-jasmine-html-reporter include links for suite-name (only). To support
running the suite, allow the filter to match any part of the test name.

Fixes #256
  • Loading branch information
johnjbarton committed May 28, 2020
1 parent 0ae10e1 commit ded4c4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function getId (s) {

function getSpecsByName (specs, name) {
specs = specs.filter(function (s) {
return s.name === name
return s.name.indexOf(name) !== -1
})
if (specs.length === 0) {
throw new Error('No spec found with name: "' + name + '"')
Expand Down
5 changes: 5 additions & 0 deletions test/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ describe('jasmine adapter', function () {
var actualSpecs = getDebugSpecToRun(location, specs)
expect(actualSpecs).toEqual([mockSpecTest])
})
it('should match with param containing only a prefix', function () {
var location = { search: '?spec=te' }
var actualSpecs = getDebugSpecToRun(location, specs)
expect(actualSpecs).toEqual([mockSpecTest])
})
it('should throw with param spec not found', function () {
var location = { search: '?spec=oops' }
expect(function () {
Expand Down

0 comments on commit ded4c4b

Please sign in to comment.